Docker参数–restart=always的作用

创建容器时没有添加参数 --restart=always ,导致的后果是:当 Docker 重启时,容器未能自动启动。

Docker 命令修改

docker container update --restart=always 容器名字

操作实例如下:

[root@localhost 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
[root@localhost mnt]# docker container update --restart=always n1
n1
[root@localhost mnt]# systemctl restart docker
[root@localhost 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
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
下一篇