Skip to content

LXC and LXD Cheat Sheet

Syed Sayem edited this page Apr 16, 2019 · 1 revision
Command Description
lxc launch [repository:][image][/release] [name] Launch a new container of a particular release of an image
lxc image list [remote:] List all images
lxc image list ubuntu: List all Ubuntu images
lxc init [repository:][imagename] Create a container but do not start it
lxc list [remote:] List all containers (running and stopped)
lxc info [remote:][name] Get detailed information about a particular container
lxc start [remote:][name] Start a stopped container
lxc stop [remote:][name] Stop a container
lxc restart [remote:][name] Restart a container
lxc pause [remote:][name] Suspend a container so its processes do not consume CPU resources
lxc delete [remote:][name] Remove a stopped container
lxc delete --force [remote:][name] Remove a running container
lxc config edit [remote:][name] Live edit a specific container's configuration
lxc profile list [remote:] List the available container "flavors"
lxc profile show [remote:][profilename] List details of a particular profile
lxc profile edit [remote:][profilename] Change the details in a profile
lxc config set [remote:][containername] [key] [value] Change a single key/value pair on the configuration of a specific container
lxc config show [remote:][name] Show detailed configuration information about a particular container
lxc exec [remote:][name] -- [command] Run a command in a container
lxc exec [remote:][name] -- /bin/bash Run bash (assuming it's installed) interactively in a container
lxc file pull [remote:][container]/[path] [destination] Download a copy from a container to a specified destination
lxc file push [filename] [remote:][container]/[path] Upload a file into a container
lxc file edit [remote:][container]/[path] Download a file from a container, open it in your default text editor, and upload it back upon save
lxc snapshot [remote:][container] [name] Create a snapshot of a container with a specified name
lxc snapshot restore [remote:][destination container] [snapshot name] Restore a container from a previous snapshot
lxc copy [remote:][source container]/[snapshot name] [remote:][new container name] Create a new container from an existing container's snapshot
lxc delete [remote:][container]/[snapshot] Delete an existing snapshot