1.docker的update命令

[root@iZbp1e9mxelwe7pwimpw8sZ ~]# docker update --help

Usage:	docker update [OPTIONS] CONTAINER [CONTAINER...]

Update configuration of one or more containers

Options:
      --blkio-weight uint16        Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
      --cpu-period int             Limit CPU CFS (Completely Fair Scheduler) period
      --cpu-quota int              Limit CPU CFS (Completely Fair Scheduler) quota
      --cpu-rt-period int          Limit the CPU real-time period in microseconds
      --cpu-rt-runtime int         Limit the CPU real-time runtime in microseconds
  -c, --cpu-shares int             CPU shares (relative weight)
      --cpus decimal               Number of CPUs
      --cpuset-cpus string         CPUs in which to allow execution (0-3, 0,1)
      --cpuset-mems string         MEMs in which to allow execution (0-3, 0,1)
      --kernel-memory bytes        Kernel memory limit
  -m, --memory bytes               Memory limit
      --memory-reservation bytes   Memory soft limit
      --memory-swap bytes          Swap limit equal to memory plus swap: '-1' to enable unlimited swap
      --pids-limit int             Tune container pids limit (set -1 for unlimited)
      --restart string             Restart policy to apply when a container exits
[root@iZbp1e9mxelwe7pwimpw8sZ ~]# 

翻译结果

选项:
      --blkio-weight uint16块IO(相对权重),介于10到1000之间,或者禁用0(默认为0)
      --cpu-period int限制CPU CFS(完全公平的调度程序)期限
      --cpu-quota int限制CPU CFS(完全公平的调度程序)配额
      --cpu-rt-period int限制CPU实时时间(以微秒为单位)
      --cpu-rt-runtime int以毫秒为单位限制CPU实时运行时间
  -c,--cpu-shares int CPU份额(相对权重)
      --cpus十进制CPU数
      --cpuset-cpus允许执行的字符串CPU(0-3,0,1)
      --cpuset-mems允许执行的字符串MEM(0-3,0,1)
      --kernel-memory字节内核内存限制
  -m,--memory bytes内存限制
      --memory-reservation字节内存软限制
      --memory-swap字节交换限制等于内存加交换:'-1'以启用无限交换
      --pids-limit int调整容器的pids限制(设置-1为无限制)
      --restart字符串容器退出时要应用的重新启动策略

2.–restart参数解释

参数名解释
no不自动重启容器. (默认值)
on-failure容器发生error而退出(容器退出状态不为0)重启容器,可以指定重启的最大次数,如:on-failure:3
unless-stopped在容器已经stop掉或Docker stoped/restarted的时候才重启容器
always在容器已经stop掉或Docker stoped/restarted的时候才重启容器,手动stop的不算

3.设置开机自启动
命令
docker update --restart=always tomcat8

4.测试结果
关闭所有容器

[root@iZbp1e9mxelwe7pwimpw8sZ ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[root@iZbp1e9mxelwe7pwimpw8sZ ~]# 

重启开机后的结果:容器已经自启动

[root@iZbp1e9mxelwe7pwimpw8sZ ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
b397fad059a2        tomcat:8            "/usr/local/tomcat8/…"   5 weeks ago         Up 8 seconds        0.0.0.0:80->8080/tcp   tomcat8
[root@iZbp1e9mxelwe7pwimpw8sZ ~]# 

5.文章参考链接
a. https://blog.csdn.net/qq_28764557/article/details/99675555
b. https://www.cnblogs.com/cwp-bg/p/9376130.html
c. https://translate.google.cn/

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐