1. docker run创建容器常见选项
1)创建容器
选项 | 描述 |
-i,-interactive | 交互式 |
-t,-tty | 分配一个伪终端 |
-d,-detach | 运行容器到后台 |
-e,-env | 设置环境变量 |
-p(小写),-publish list | 发布容器端口到主机 |
-P(大写),-publish -all | 发布容器所有EXPOSE的端口到宿主机随机端口 |
--name string | 指定容器名称 |
-h,-hostname | 指定容器主机名 |
-ip string | 指定容器IP,只能用于自定义网络 |
-network | 连接容器到一个网络 |
-v,-volume list | 绑定挂载一个卷 |
-restart string | 容器退出时重启策略,默认no,可选值:【always|on-failure】 |
2)容器资源限制
选项 | 描述 |
-m,--memory | 容器可以使用的最大内存量 |
-memory-swap | 允许交换到磁盘的内存量 |
-memory-swappiness=<0-100> | 容器使用swap分区交换的百分比(0-100,默认为-1) |
--oom-kill-disable | 禁止OOM killer |
--cpus | 可以使用的cpu数量 |
--cpuset-cpus | 限制容器使用特定的cpu核心,如(0-3, 0,1) |
--cpu-shares | cpu共享(相对权重) |