问题描述
我有一些容器,它们全部在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:
推荐答案
从注释看来,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中不重启的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!