Delete
Overview
If you want to permanently delete a specific canister or all canisters for a specific project on a given deployment (either local or remote), you can do so by running the command:
dfx canister delete <canister-name> // Delete local canister
dfx canister delete <canister-name> --network=ic // Delete canister on mainnet
Deleting a canister removes the canister identifier, code, and state. Before you can delete a canister, however, you must first stop the canister to clear any pending message requests or replies.
Delete all canisters
To delete all canisters for a project:
Step 1: Open a new terminal and navigate to your project directory.
Step 2: Start the local canister execution environment, if necessary.
In most cases, this step is only necessary if you are running the canisters locally.
If you were deleting canisters to run on a remote execution environment, e.g. ICP blockchain, you would include the --network
command-line option to perform tasks on the environment specified under this parameter.
Step 3: Check the status of the project canisters running on the local canister execution environment by running the following command:
dfx canister status --all
Step 4: Stop all of the project canisters by running the following command:
dfx canister stop --all
Step 5: Delete all of the project canisters by running the following command:
dfx canister delete --all