docker 不会在启动时启动,端口在没有进程的情况下打开

docker 不会在启动时启动,端口在没有进程的情况下打开

在 Ubuntu 20 下使用 docker 20.10.2。使用 docker-compose 部署堆栈。

当我重新启动主机时,即使容器已设置,也不会自动restart: unless-stopped启动restart: always

奇怪的是,当我尝试手动重新部署堆栈(docker-compose up -d)时,我收到一堆bind错误:

Creating influxdb    ... error
 starting userland proxy: listen tcp 0.0.0.0:8053: bind: address already in use
Creating portainer   ... error

ERROR: for influxdb  Cannot start service influxdb: driver failed programming external connectivity on endpoint influxdb (c96dbf129ad4c7c1e4ffe01a281f680a0174b277c9364ae8de41d864444319f4): Error startingCreating mariadb     ... error
WARNING: Host is already in use by another container

ERROR: for portainer  Cannot start service portainer: driver failed programming external connectivity on endpoint portainer (c19930b176b21051089da6b6eb14c225d74a6bed867ab42bd23b61a81be794d8): Error starting userland proxy: listen tcp 0.0.0.0:9000: bind: address already in use
WARNING: Host is already in use by another container

ERROR: for mariadb  Cannot start service mariadb: driver failed programming external connectivity on endpoint mariadb (184e22f74c14126e8c5d4129e4a609b11f102ffcee9612c941e519f12e92d708): Error starting userland proxy: listen tcp 0.0.0.0:3306: bind: address already in use
Creating traefik     ... error

ERROR: for traefik  Cannot start service traefik: driver failed programming external connectivity on endpoint traefik (ddb84136d437d378547c39bceef5b06e169f2f72936cf092bd025b84eb7fc357): Error starting us

netstat确实显示它们已使用,但它们似乎不附加到任何进程

$ netstat -tulpn | grep LISTEN
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:9000            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:9001            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:6443            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:9229            0.0.0.0:*               LISTEN      -
$ lsof -i:3306
$ ps -p 3306 -o comm=
$ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
$

除了这些之外,我没有看到任何有趣的东西journal -xab

Jan 21 22:20:04 hassvm systemd[1]: run-docker-runtime\x2drunc-moby-e3aa5cd3fb4175c7b46de9d5dcd412b2baffa516a29afbd83dd727791e2cfbac-runc.V7HkWR.mount: Succeeded.
-- Subject: Unit succeeded
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit run-docker-runtime\x2drunc-moby-e3aa5cd3fb4175c7b46de9d5dcd412b2baffa516a29afbd83dd727791e2cfbac-runc.V7HkWR.mount has successfully entered the 'dead' state.
Jan 21 22:20:04 hassvm systemd[4337]: run-docker-runtime\x2drunc-moby-e3aa5cd3fb4175c7b46de9d5dcd412b2baffa516a29afbd83dd727791e2cfbac-runc.V7HkWR.mount: Succeeded.
-- Subject: Unit succeeded
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit UNIT has successfully entered the 'dead' state.
Jan 21 22:20:10 hassvm systemd[1]: run-docker-runtime\x2drunc-moby-efb800957288657eb83568a3cf9c6669fc3c1c7782e678effa01f4c4f4d5a21a-runc.TpI8YC.mount: Succeeded.
-- Subject: Unit succeeded
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit run-docker-runtime\x2drunc-moby-efb800957288657eb83568a3cf9c6669fc3c1c7782e678effa01f4c4f4d5a21a-runc.TpI8YC.mount has successfully entered the 'dead' state.
Jan 21 22:20:10 hassvm systemd[4337]: run-docker-runtime\x2drunc-moby-efb800957288657eb83568a3cf9c6669fc3c1c7782e678effa01f4c4f4d5a21a-runc.TpI8YC.mount: Succeeded.
-- Subject: Unit succeeded
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit UNIT has successfully entered the 'dead' state.

虽然不知道这意味着什么。

当我重新启动 docker 服务 ( sudo systemctl restart docker.service) 时,没有任何变化。仅当我重新启动套接字时才有效 ( sudo systemctl restart docker.socket)

这是怎么回事?有永久的解决方案吗?

答案1

就我而言,这是因为安装了 apt 和 snap 版本的 docker 造成的。我通过运行删除了 docker 的 snap 版本sudo snap remove docker

重新启动后,docker 容器再次启动,我为守护进程配置的代理设置也正常工作。

答案2

就我而言,这是 docker 网络的问题,而我连接的是 VPN。命令 o/p 建议查看journal -xe,这并不是真正有用,正如OP已经指出的那样。发现了有用的日志,/var/log/syslog其中抱怨dockerd无法列出网络控制器。对于某些人来说,它会抱怨一些其他错误,例如无法连接等。

当我断开与 VPN 的连接时,docker 守护进程服务干净地启动了。

相关内容