Command LXD (container)
# initialize LXD
lxd init
# create container
lxc launch ubuntu:18.04 <container_name>
lxc launch ubuntu:16.04 <container_name>
# create container on storage-pool
lxc launch ubuntu:18.04 <container_name> -s <storage-pool>
# attach to container
lxc exec <container_name> -- /bin/bash
# stop container
lxc stop <container_name>
# delete container
lxc delete <container_name>
# clone container - can do this online
lxc copy <source_container_name> <target_container_name>
# list storage
lxc storage list
# set root device to storage
lxc profile device add default root disk path=/ pool=<storage>
# delete storage (after re-initialization)
lxc storage delete <storage_name>
# create another storage pool
lxc storage create <storage-pool-name> <fs-type> source=/dev/<block>
# create container centos
lxc launch images:centos/7
# rename container (offline)
lxc rename <old-name> <new-name>
# set limit memory
lxc config set <container-name> limits.cpu 2
lxc config set <container-name> limits.memory 32000MB
# get limit memory
lxc config get <container-name> limits.memory
# list network
lxc network list
# delete network
lxc network delete lxdbr0
# snapshot
lxc snapshot <container_name> <snapshot_name>
# list process in container
cd /sys/fs/cgroup/memory/lxc && for i in $(echo */); do echo $i && cat $i/cgroup.procs; done
# add device to container (passthrough)
# prereqs: device formatted, and container is down
lxc config device add <plb> <disk-plb> disk source=/dev/sdx path=/opt/plb-storage
lxc config device add plb disk-plb disk source=/dev/vdd1 path=/opt/plb-storage
# list passthrough device on container
lxc config device list plb
# remove passthrough device on container
lxc config device remove plb disk-plb
0 Komentar