温馨提示:本文共1726个字,读完预计5分钟。
创建容器时没有添加参数 –restart=always ,导致的后果是:当 Docker 重启时,容器未能自动启动。
现在要添加该参数怎么办呢,方法有二:
1、Docker 命令修改
docker container update –restart=always 容器名字
1
实例操作如下:
[root@rabbitmq ~]# docker container update –restart=always rabbitmq
rabbitmq
[root@rabbitmq ~]# systemctl restart docker
[root@rabbitmq ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
043b63bbda84 redis:5.0.5 "docker-entrypoint.s…" 46 hours ago Up 7 seconds 0.0.0.0:7005->7005/tcp, 6379/tcp, 0.0.0.0:17005->17005/tcp redis-7005
670ddcd33d91 redis:5.0.5 "docker-entrypoint.s…" 46 hours ago Up 7 seconds 0.0.0.0:7004->7004/tcp, 6379/tcp, 0.0.0.0:17004->17004/tcp redis-7004
b3785e9796c6 redis:5.0.5 "docker-entrypoint.s…" 46 hours ago Up 7 seconds 0.0.0.0:7003->7003/tcp, 6379/tcp, 0.0.0.0:17003->17003/tcp redis-7003
42f19c26df01 redis:5.0.5 "docker-entrypoint.s…" 46 hours ago Up 8 seconds 0.0.0.0:7002->7002/tcp, 6379/tcp, 0.0.0.0:17002->17002/tcp redis-7002
d7f31eec4052 redis:5.0.5 "docker-entrypoint.s…" 46 hours ago Up 8 seconds 0.0.0.0:7001->7001/tcp, 6379/tcp, 0.0.0.0:17001->17001/tcp redis-7001
874b9667b48c redis:5.0.5 "docker-entrypoint.s…" 46 hours ago Up 8 seconds 0.0.0.0:7000->7000/tcp, 6379/tcp, 0.0.0.0:17000->17000/tcp redis-7000
b045b37d244d rabbitmq:management "docker-entrypoint.s…" 2 days ago Up 8 seconds 4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp rabbitmq
[root@rabbitmq ~]#
————————————————
版权声明:本文为CSDN博主「carcoon」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/carcoon/article/details/105253898