码迷,mamicode.com
首页 > 系统相关 > 详细

Ubuntu下LXC/LXD常用配置

时间:2018-08-02 10:19:10      阅读:1238      评论:0      收藏:0      [点我收藏+]

标签:delete   publish   详细   res   upd   new   初始化   containe   镜像   

# ubuntu版本
sudo lsb_release -a
# 初始化配置 Initial configuration
sudo lxd init
# container 创建ubuntu容器样例
lxc launch ubuntu:16.04 first
# 显示可用镜像
lxc image list images: | less
# 显示当前远程可用
lxc remote list
# 显示容器网络
lxc network show lxdbr0
# 显示容器
lxc list
# 运行容器bash
lxc exec first -- /bin/bash
# 直接运行容器命令
lxc exec first -- apt-get update
# 文件传输下载
lxc file pull first/etc/hosts .
# 文件传输上传
lxc file push hosts first/tmp/
# 停止容器
lxc stop first
# 删除容器
lxc delete first
# 显示容器信息
lxc info first
# 本地配置
lxc config edit <container>
# 显示容器详细信息
lxc config show first
lxc config show <container>
# 内存查看 free -m
lxc exec first -- free -m
# 设置内存最大值
lxc config set first limits.memory 2048MB
# 执行升级
lxc exec first -- apt-get update
lxc exec first -- apt-get dist-upgrade -y
lxc exec first -- apt-get autoremove --purge -y
# 暂停
lxc pause <container>
# 快照 Snapshots -stateful选项包含所有状态
lxc snapshot first clean
# 列出所有的快照
lxc info <container>
lxc snapshot <container> <snapshot name>
# 快照恢复
lxc restore first clean
# 从快照生成容器镜像
lxc publish first/clean --alias clean-ubuntu
# 启动快照容器镜像
lxc launch clean-ubuntu second
# 删除容器镜像方式一
lxc delete --force second
# 删除容器镜像方式二
lxc delete -f second
# 删除一个快照
lxc delete <container>/<snapshot name>
# 从快照中创建一个新的容器
lxc copy <source container>/<snapshot name> <destination container>
# 给快照重命名
lxc move <container>/<snapshot name> <container>/<new snapshot name>
# lxc运行docker
lxc config set first security.nesting true
lxc restart first

Ubuntu下LXC/LXD常用配置

标签:delete   publish   详细   res   upd   new   初始化   containe   镜像   

原文地址:http://blog.51cto.com/johjoh/2153408

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!