Docker:向已经创建的容器添加重启策略 [英] Docker: Add a restart policy to a container that was already created

查看:24
本文介绍了Docker:向已经创建的容器添加重启策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到 Docker 添加了一些叫做重启策略的东西来处理容器的重启,例如重启.

I see that Docker has added something called restarting policies to handle restart of containers in case of, for instance, reboot.

虽然这非常有用,但我发现重启策略命令只适用于 docker run 而不是 docker start.所以我的问题是:

While this is very useful, I see that the restart policy command just work with docker run and not docker start. So my question is:

有没有什么办法可以将重启策略添加到过去已经创建的容器中?

Is there any way to add restarting policies to a container that was already created in the past?

推荐答案

在 docker 的最新版本(从 1.11 开始)中,您有一个 update 命令:

In recent versions of docker (as of 1.11) you have an update command:

docker update --restart=always <container>

这篇关于Docker:向已经创建的容器添加重启策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆