LinuxCommandLibrary

lxc-destroy

Delete an existing LXC container

TLDR

Delete a container

$ sudo lxc-destroy [container_name]
copy

Display help
$ lxc-destroy [[-?|--help]]
copy

SYNOPSIS

lxc-destroy [-f] [-n name]

PARAMETERS

-n name
    Specifies the name of the container to destroy.

-f
    Forces the container to be stopped and then destroyed. Use with caution as it may lead to data loss.

DESCRIPTION

The lxc-destroy command permanently removes an existing LXC container and all associated data. This includes the container's root filesystem, configuration files, and any other resources allocated to it.
It's crucial to ensure that the container is stopped before running lxc-destroy. Otherwise, data loss or corruption might occur. lxc-destroy offers options for force stopping the container, but this should be used with caution.
This command differs from lxc-stop which only stops the container but keeps all the container's data for future use. After running lxc-destroy, the container is unrecoverable, so it's vital to back up any important data before executing this command.

CAVEATS

Destroying a container is an irreversible process. Always verify the container name before running lxc-destroy. Using the -f option can cause data corruption if the container is actively writing to disk.

ERROR HANDLING

If the container is not found or there are issues during the destroy process, lxc-destroy will return an error code. Check the logs (usually under /var/log/lxc/) for more detailed information.

SEE ALSO

Copied to clipboard