【问题标题】:Managing docker image throw systemctl管理 docker image throw systemctl
【发布时间】:2017-07-25 14:04:24
【问题描述】:

我构建了一个包含 Nginx 的 docker 镜像,它的配置让我们称之为 A 当我手动构建它时,它的构建和运行没有错误但是当我决定管理 docker image throw systemctl 它也没有给我任何错误,但是当输入: sudo systemctl status A. 服务它处于非活动状态(死)

Here is my nginx.service file

Here is the output given when managed throw systemctl

我该怎么做才能让它在启动时处于活动状态? 在此先感谢

【问题讨论】:

    标签: nginx docker systemd systemctl


    【解决方案1】:

    您不能像您的 ExecStartPre 字段中那样杀死一个不存在的容器。您可以首先:检查容器是否正在运行并在需要时将其终止。我觉得太复杂了。

    如果您有最新的 docker 版本 (> 1.10),请选择重启策略:https://docs.docker.com/engine/admin/start-containers-automatically/

    docker run --restart always mynginx
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-15
      • 2019-03-06
      • 1970-01-01
      • 2023-01-28
      • 2012-03-24
      • 1970-01-01
      • 2018-09-05
      相关资源
      最近更新 更多