如何在使用 ansible 安装时保留 docker 个容器 运行
How to keep docker containers running when they are installed with ansible
我一直在使用 ansible docker module 在服务器上安装多个容器。我有带有服务 运行ning 的容器,比如 mysql 或 mongodb.
但有时我的容器会停止 运行ning,所以我必须再次 运行 剧本才能让它们再次 运行ning 回来。
我一直在尝试使用 supervisord 并将 docker 命令写入主管配置中的 运行 容器。但是通过这样做,就不需要使用 ansible docker 模块了。我很乐意继续使用它,因为它使 docker 配置更简洁、更简单。
是否有更好的方法使用 ansible docker 模块来实现此目的?正确的方法是什么?
docker
module has a restart_policy
option, which translates to the --restart
parameter of the docker command.
通过将此应用到您的任务,您将获得所需的行为:
restart_policy: on-failure
我一直在使用 ansible docker module 在服务器上安装多个容器。我有带有服务 运行ning 的容器,比如 mysql 或 mongodb.
但有时我的容器会停止 运行ning,所以我必须再次 运行 剧本才能让它们再次 运行ning 回来。
我一直在尝试使用 supervisord 并将 docker 命令写入主管配置中的 运行 容器。但是通过这样做,就不需要使用 ansible docker 模块了。我很乐意继续使用它,因为它使 docker 配置更简洁、更简单。
是否有更好的方法使用 ansible docker 模块来实现此目的?正确的方法是什么?
docker
module has a restart_policy
option, which translates to the --restart
parameter of the docker command.
通过将此应用到您的任务,您将获得所需的行为:
restart_policy: on-failure