How to delete container with lxc (LXD) command on Linux

To delete a container using the lxc (LXD) command on Linux, you can use the following command:

lxc delete <container name>

For example, if the container name is “mycontainer”, you would run the following command:

lxc delete mycontainer

This command will delete the container and all its associated data, such as its configuration, snapshots, and storage.

If you want to delete a container but keep its data, you can use the following command:

lxc delete --force --keep-data <container name>

You can also use the lxc list command to check the containers that you have created, and the lxc stop command to stop a running container before deleting it.

Note: If the container is running, you will need to stop it before being able to delete it. If you don’t want to stop the container you can use the --force option as mentioned above.

Leave a Comment