lxc usage

lxc usage


list images in repo
lxc image list images:


list local images
lxc image list local:


launch/create container from image
lxc launch images:opensuse/15.3 $CONTAINERNAME


launch/create vm from image
lxc launch images:opensuse/15.3 $CONTAINERNAME --vm


delete container/vm
lxc stop $CONTAINERORVMNAME
lxc delete $CONTAINERORVMNAME
# or
lxc delete -f $CONTAINERORVMNAME


execute command in container
lxc exec $CONTAINERNAME /bin/$COMANDNAME


touch to container shell
lxc shell $CONTAINERNAME
# or
lxc exec $CONTAINERNAME /bin/bash


push file to containert
lxc file push /path/to/local/file $CONTAINERNAME/path/to/dir/in/container/


pull file from container
lxc file pull $CONTAINERNAME/path/to/file/in/container /path/to/local/dir/


list local container/vm
lxc ls


create snapshot
lxc snapshot $CONTAINERORVMNAME $SNAPSHOTNAME


list snapshots container/vm
lxc info $CONTAINERORVMNAME


restore container/vm to snapshot
lxc restore $CONTAINERORVMNAME $SNAPSHOTNAME


delete container/vm snapshot
lxc delete $CONTAINERORVMNAME/$SNAPSHOTNAME


mount directory from host to container
lxc config device add $CONTAINERNAME $SHARENAME $DEVICETYPE_disk source=/path/on/host path=/path/on/container/


delete shared host directory from container
lxc config device remove $CONTAINERNAME $SHARENAME


create container/vm backup:
lxc export $CONTAINERNAME /path/to/$BACKUPNAME.tar.gz --compression gzip


restore container/vm backup:
lxc import /path/to/$BACKUPNAME.tar.gz


delete container backup:
lxc query -X DELETE /1.0/containers/$CONTAINERNAME/backups/$BACKUPNAME

Содержание