基本操作
本文介绍容器主机的常见climc命令
创建容器主机
- 创建无数据盘的容器主机
# 创建一个名称为test-web的容器主机
# 内存配额512m
# 容器镜像为 registry.cn-beijing.aliyuncs.com/yunion/web:v4.0.2
# 对接IP子网vnet221
# 容器内对外暴露tcp 80端口,宿主机自动分配端口映射
# 创建好后自动运行
climc pod-create test-web \
512 \
registry.cn-beijing.aliyuncs.com/yunion/web:v4.0.2 \
--net vnet221 \
--net-port-mapping port=80,protocol=tcp \
--auto-start
- 创建一个带数据盘的容器主机
# 创建一个名称为test-climc的容器主机
# 内存配额2g
# 容器镜像为 registry.cn-beijing.aliyuncs.com/yunion/climc:v4.0.2
# 创建好后自动运行
# 容器运行命令 sleep 3600
# 容器接入网络 vnet221
# 创建一个10g大小的本地数据盘,格式为raw,格式化为ext4
# 将该数据盘挂载到容器的 /data
climc pod-create test-climc \
2g \
registry.cn-beijing.aliyuncs.com/yunion/climc:v4.0.2 \
--auto-start \
--command sleep --args 3600 \
--net vnet221 \
--disk local:10g:raw:ext4 \
--volume-mount 'mount_path=/data,disk_index=0'
- 创建一个rootfs持久化的容器主机
# 创建一个名称为test-rootfs的容器主机
# 内存配额2g
# 容器镜像为 registry.cn-beijing.aliyuncs.com/yunion/climc:v4.0.2
# CPU配额为2核
# 创建好后自动运行
# 容器运行命令 sleep 3600
# 容器接入网络 vnet221
# 创建一个10g大小的本地磁盘,格式为raw,格式化为xfs
# 将该磁盘作为容器的根目录
# 创建一个20g大小的本地磁盘,格式为raw,格式化为xfs
# 将该磁盘挂载到容器的/data
# 启用lxcfs模拟CPU和内存信息
climc pod-create test-rootfs \
2g \
registry.cn-beijing.aliyuncs.com/yunion/climc:v4.0.2 \
--ncpu 2 \
--auto-start \
--command sleep --args 3600 \
--net vnet221 \
--disk local:10g:raw:xfs \
--root-fs disk_index=0,sub_directory=/rootfs \
--disk local:20g:raw:xfs \
--volume-mount mount_path=/data,disk_index=1 \
--enable-lxcfs