รวมคำสั่งที่ใช้งานบ่อยๆ
คำสั่งที่ใช้ในการติดตั้ง
sudo snap install lxd sudo lxd init sudo usermod --append --groups lxd sarankon
การจัดการเกี่ยวกับ Container
# Create new container lxc launch images:<alias-name> <container-name> lxc launch images:alpine/3.10 alpine # List the list of container lxc list # Show the info of container, *snapshot show here! lxc info <container-name> # Start and Stop container lxc start <container-name> lxc stop <container-name> # Delete container lxc delete <container-name> lxc delete <container-name> --force # Run command in container lxc exec <container-name> -- <command> # Run apt update command lxc exec <container-name> -- apt update # Use bash in container lxc exec <container-name> -- bash # Use default editor to edit file in container lxc file edit <container-name>/<path/file.txt> # Push file to container lxc file push <file> <container-name>/<path> # Create snapshot lxc snapshot <container-name> <snapshot-name> # Restore snapshot lxc restore <container-name> <snapshot-name> # Delete snapshot lxc delete <container-name>/<snapshot-name> # Create container from snapshot lxc copy <container-name>/<snapshot-name> <new-container-name> # lxc start <container-name> // after create from snapshot
การจัดการเกี่ยวกับ Images
# Show the list of remote server lxc remote list +-----------------+------------------------------------------+ | NAME | URL | +-----------------+------------------------------------------+ | images | https://images.linuxcontainers.org | +-----------------+------------------------------------------+ | local (default) | unix:// | +-----------------+------------------------------------------+ | ubuntu | https://cloud-images.ubuntu.com/releases | +-----------------+------------------------------------------+ | ubuntu-daily | https://cloud-images.ubuntu.com/daily | +-----------------+------------------------------------------+ # lxc image list <remote-name> # Default is local, not have to type lxc image list lxc image list local: lxc image list images: lxc image list images: | grep -C1 -i centos lxc image copy images:<alias-name> local: --alias <alias-name> lxc image delete <alias-name> # Publish, Export and Import lxc publish <container-name>/<snapshot-name> lxc image export <alias-name> <path> lxc image import <tar.gz file> --alias <alias-name> # tar ball 'tar.gz' structure # metadata.yaml, rootfs, templates (hostname.tpl, hosts.tpl)
การสร้าง Remote Host
# Host 1 lxc remote list # Host 2 lxc config set core.https_address "[::]:8443" lxc config set core.trust_password <password> # Host 1 lxc remote add <remote-name> <ip-address> --password=<password> lxc list <remote-name> lxc image list <remote-name:>
 
 
ไม่มีความคิดเห็น:
แสดงความคิดเห็น