docker容器设置开机自启动

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/

  • 5
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值