Files
chill_notes/Docker/centos7设置docker开机自启动,并设置容器自动重启.md
2026-04-21 17:41:25 +08:00

12 lines
837 B
Markdown
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
**1****、设置****docker****开机启动**
systemctl enable docker
**2****、设置容器自动重启**
**1****)、创建容器时设置**
docker run -d --restart=always --name 设置容器名 使用的镜像(上面命令 --name后面两个参数根据实际情况自行修改
 --restart具体参数值详细信息       no容器退出时不重启容器       on-failure 只有在非0状态退出时才重新启动容器       always      无论退出状态是如何,都重启容器;
**2****)、修改已有容器,使用****update**
docker update --restart=always 容器ID(或者容器名)
容器ID或者容器名根据实际情况修改
> 来自 <[https://www.cnblogs.com/763977251-sg/p/11839918.html](https://www.cnblogs.com/763977251-sg/p/11839918.html)>