更新后始终重启的容器始终在docker-compose.yml中不重启 [英] Containers not restarted after update with restart always in docker-compose.yml

查看:622
本文介绍了更新后始终重启的容器始终在docker-compose.yml中不重启的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些容器,它们全部在docker-compose文件中具有始终重启的值,如下所示:

I have some containers which all of them have the always restart value in the docker-compose file like this:

version: "3.7"
services:

  container:
    image: ghost:latest
    container_name: some_container
    restart: always
    depends_on:
       - ...
    ports:
       - ...
...

一旦操作系统(Flatcar Linux/CoreOS)进行了自我更新,则所有容器都不会重新启动.但是,如果我只是执行 $ sudo docker ps ,则所有容器都将立即启动.这是怎么回事,我该如何解决,以便我的容器在更新后自动重新启动?

As soon as the OS (Flatcar Linux / CoreOS) has updated itself none of the containers restart. But if I just do $ sudo docker ps all of the containers starts at once. Whats up with that and how do I fix it so my containers automatically restarts after an update?

不确定我的问题有什么不清楚之处,重新启动:始终已打开.除非我在文档中缺少一些重要的内容,否则即使重启docker守护进程(在OS重启之后),该命令也应该重启容器.

Not sure what is unclear about my question, restart: always is turned on. Unless I'm missing some vital thing in the documentation, this command should restart the container even if the docker daemon is restarted (after an os reboot).

从下面复制我的评论之一:

Copy of one my comments from below:

好的,请在这里帮助我.如您所见,我有重新启动:始终打开.所有这些容器已启动成功并且运行良好.然后,操作系统会自我更新自动并重新启动.在此重启后,码头工人守护程序重新启动.但是由于某些原因,我运行的容器在 RESTART:始终处于打开状态下,无法启动.如果我输入我的服务器此时,键入 sudo docker ps 列出我正在运行的容器,突然所有的容器都启动了,我看到了列表.所以为什么即使守护程序正在运行,容器也没有启动吗?

Ok, so help me out here. As you can see in my question, I have restart: always turned on. All these containers are started successfully and are running well. Then the OS updates itself automatically and restarts itself. After this restart the docker daemon is restarted. But for some reasons the containers I had running WITH RESTART: ALWAYS turned on DOES NOT START. If I enter my server at this moment, type sudo docker ps to list my running containers, suddenly all containers are booted up and I see the list. So why wasn't the containers started, even though the daemon is running?

推荐答案

从注释看来,docker服务未配置为在引导时自动启动.Docker是一个客户端服务器应用程序,服务器从systemd运行,并为客户端用于与服务器通信的docker套接字提供单独的服务.因此,使用docker命令进行的任何调用都有可能通过敲击docker套接字来启动服务器.

From the comments it appears the docker service was not configured to automatically start on boot. Docker is a client server app, and the server runs from systemd with a separate service for the docker socket used by the client to talk to the server. Therefore it's possible for any call with the docker command to cause the server to get launched by hitting the docker socket.

可以使用以下命令检查systemd中的服务状态:

The service state in systemd can be checked with:

systemctl status docker

或者您可能要检查:

systemctl is-enabled docker

可以通过以下方式手动启动:

It can be manually started with:

systemctl start docker

并且可以将其开头为:

systemctl enable docker

以上所有命令都需要以root用户身份运行.

All of the above commands need to be run as root.

这篇关于更新后始终重启的容器始终在docker-compose.yml中不重启的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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