1、安装
sudo apt install lxd lxd-client
查看服务状态
sudo systemctl status lxd
查看版本
lxd --version
初始化
lxd init
2、使用
查看映像服务器列表
lxc remote list
查看服务器上(ubuntu:、ubuntu-daily:、images:)虚拟机映像
lxc image list ubuntu: ubuntu官网稳定版
lxc image list ubuntu-daily: ubuntu官网每日版
lxc image list images: linux容器官网版
查看本地虚拟机
lxc image list
创建并启动myserver容器
lxc launch ubuntu:18.04 u1804
lxc launch ubuntu-daily:19.10 u1910
lxc launch images:ubuntu/bionic/amd64 u180402
容器重命令
lxc rename u1804 u1804new
查看本地linux容器
lxc list
查看容器信息
lxc info u1804
启动/重启/停止/删除容器
lxc start/restart/stop/delete u1804
在容器中执行命令,进入容器bash shell
lxc exec u1804 -- /bin/bash
exit退出
从容器拷出文件到当前目录
lxc file pull u1804/etc/hostname /home/
复制文件到容器
lxc file push ~/a.txt u1804/root/
容器添加代理设备公开WEB访问(主机254)
http://192.168.1.254
lxc config device add us1 myproxy1 proxy listen=tcp:0.0.0.0:80 connect=tcp:127.0.0.1:80
查看容器配置
lxc config show u1804
主机目录或硬盘挂载到容器
lxc config device add u1804 mydisk disk source=/主机目录/ path=/容器目录挂载点/