LXC commands cheat-sheet

Useful commands

List available image servers

lxc remote list

List images on server

lxc image list {:ImageServerName:}:

Search for images

lxc image list {:ImageServerName:}: {:SearchTerm:}

How I like to search because I feel it yields more comprehensive results

lxc image list {:ImageServerName:}: | grep -i '{:SearchTerm:}'

Create a container based on alias or thumbprint

lxc launch {:ImageServerName:}:{:ImageAliasOrThumbprint:} {:ContainerName:}

Standard start/stop/restart/delete operations

lxc {:StandardOperation:} {:ContainerName:}

Display container information

lxc info {:ContainerName:}

Take snapshot of container

lxc snapshot {:ContainerName:} {:SnapshotName:}

Restore snapshot of container

lxc restore {:ContainerName:} {:SnapshotName:}

Delete snapshot of container

lxc delete {:ContainerName:}/{:SnapshotName:}

List container profiles

lxc profile list

Show container profile details

lxc profile show {:ProfileName:}

Assign profile to container

lxc profile assign {:ContainerName:} {:ProfileName:}

Show container configuration

lxc config show {:ContainerName:}

Set configuration option for container

lxc config set {:ContainerName:} {:ConfigOption:} "{:ConfigValue:}"

List devices added to container

lxc config device list {:ContainerName:}

Show details for devices added to container

lxc config device show {:ContainerName:}

Add storage device to container

lxc config device add {:ContainerName:} {:DeviceName:} disk "source={:LocalSourceFolder:}" "path={:ContainerMountPath:}"

Remove device from container

lxc config device remove {:ContainerName:} {:DeviceName:}

Tags: #Containers #Lxc