refert to how-to-start-docker-containers-automatically-after-a-reboot
1.对于docker服务的自动重启[root@iZj6cj20vqe3q7vt49zoxdZ ~]# systemctl enable docker Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service. [root@iZj6cj20vqe3q7vt49zoxdZ ~]#2.对于docker容器的自动重启
假设你已经通过docker run 启动了一个容器,则可以通过docker update 去启动容器的自动启动策略。
docker update --restart unless-stopped container_id
| 参数 | 描述 |
|---|---|
| no | 这个是默认值,意思是容器任何时候都不会自动启动 |
| on-failure | 这将在出现错误并且容器崩溃时重新启动容器 |
| always | 如果容器停止,请始终重新启动容器 |
| unless-stopped | 除非手动停止,否则容器将始终重新启动 |



