docker重启 容器自动重启
创建容器时添加参数 --restart=always
后,当 docker 重启时,容器自动启动。
使用方法:
docker container update --restart=always 容器名字
操作实例如下:
[ mnt]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 46cdfc60b7a6 nginx "nginx -g ‘daemon ..." About a minute ago Up 42 seconds 80/tcp n3 79d55a734c26 nginx "nginx -g ‘daemon ..." About a minute ago Up 42 seconds 80/tcp n2 f7b2206c019d nginx "nginx -g ‘daemon ..." About a minute ago Up 46 seconds 80/tcp n1 [ mnt]# docker container update --restart=always n1 n1 [ mnt]# systemctl restart docker [ mnt]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 46cdfc60b7a6 nginx "nginx -g ‘daemon ..." 2 minutes ago Exited (0) 5 seconds ago n3 79d55a734c26 nginx "nginx -g ‘daemon ..." 2 minutes ago Exited (0) 5 seconds ago n2 f7b2206c019d nginx "nginx -g ‘daemon ..." 2 minutes ago Up 2 seconds 80/tcp n1
相关推荐
nginxs 2020-11-14
时光流水 2020-09-23
yangkang 2020-09-10
yangkang 2020-11-09
ChlatZed 2020-11-11
xysoul 2020-11-03
lnkToKing 2020-10-29
ChlatZed 2020-10-27
dusuanyun 2020-09-21
newisI 2020-09-01
fearlessxjdx 2020-09-04
王道革 2020-11-25
bwyyziq 2020-11-22
pigsmall 2020-11-19
changecan 2020-11-19
helloWorldAndYou 2020-11-16
红石丶 2020-11-13
WanKaShing 2020-11-12
yangkang 2020-11-12