【问题标题】:Unable to docker-compose up any project无法 docker-compose 任何项目
【发布时间】:2021-01-17 15:40:03
【问题描述】:

每当我尝试 docker-compose up 任何项目时,都会出现以下错误。 我试过有和没有 sudo 我只在这台机器上遇到这个问题。我可以在我的 Mac 和 Amazon WorkSpace 上运行相同的容器。

(myslabs) [austin@localhost myslabs]$ sudo docker-compose up
[sudo] password for austin: 
Traceback (most recent call last):
  File "urllib3/connectionpool.py", line 677, in urlopen
  File "urllib3/connectionpool.py", line 392, in _make_request
  File "http/client.py", line 1252, in request
  File "http/client.py", line 1298, in _send_request
  File "http/client.py", line 1247, in endheaders
  File "http/client.py", line 1026, in _send_output
  File "http/client.py", line 966, in send
  File "docker/transport/unixconn.py", line 43, in connect
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "requests/adapters.py", line 449, in send
  File "urllib3/connectionpool.py", line 727, in urlopen
  File "urllib3/util/retry.py", line 403, in increment
  File "urllib3/packages/six.py", line 734, in reraise
  File "urllib3/connectionpool.py", line 677, in urlopen
  File "urllib3/connectionpool.py", line 392, in _make_request
  File "http/client.py", line 1252, in request
  File "http/client.py", line 1298, in _send_request
  File "http/client.py", line 1247, in endheaders
  File "http/client.py", line 1026, in _send_output
  File "http/client.py", line 966, in send
  File "docker/transport/unixconn.py", line 43, in connect
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionRefusedError(111, 'Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "docker/api/client.py", line 205, in _retrieve_server_version
  File "docker/api/daemon.py", line 181, in version
  File "docker/utils/decorators.py", line 46, in inner
  File "docker/api/client.py", line 228, in _get
  File "requests/sessions.py", line 543, in get
  File "requests/sessions.py", line 530, in request
  File "requests/sessions.py", line 643, in send
  File "requests/adapters.py", line 498, in send
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionRefusedError(111, 'Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "bin/docker-compose", line 3, in <module>
  File "compose/cli/main.py", line 67, in main
  File "compose/cli/main.py", line 123, in perform_command
  File "compose/cli/command.py", line 69, in project_from_options
  File "compose/cli/command.py", line 132, in get_project
  File "compose/cli/docker_client.py", line 43, in get_client
  File "compose/cli/docker_client.py", line 170, in docker_client
  File "docker/api/client.py", line 188, in __init__
  File "docker/api/client.py", line 213, in _retrieve_server_version
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', ConnectionRefusedError(111, 'Connection refused'))
[142201] Failed to execute script docker-compose

我找不到任何关于任何类似问题的文章。 我正在使用在 Windows 上的 VirtualBox 内运行的 Centos 8。

(myslabs) [austin@localhost myslabs]$ docker --version
Docker version 19.03.13, build 4484c46d9d
(myslabs) [austin@localhost myslabs]$ docker-compose --version
docker-compose version 1.27.3, build 4092ae5d

任何帮助将不胜感激。

【问题讨论】:

  • 试图连接到通过 TCP 暴露的远程 docker 守护进程? docker 守护进程是否正在运行?即docker ps可以吗?
  • 所以我检查了一下,docker没有运行……一个菜鸟的错误。问题出在 docker 守护进程配置上。但是现在在构建映像时无法解析“deb.debian.org”。我的配置如下所示:{ "dns":["8.8.4.4", "8.8.8.8"] }

标签: linux docker docker-compose centos8


【解决方案1】:

我也遇到了和你一样的错误,我的问题是docker没有启动。

  • 检查码头状态systemctl status docker

  • systemctl start docker

  • docker-compose up再试一次

  • systemctl enable docker 开机启动

【讨论】:

  • 有没有办法自动检查并重新发出 systemctl start docker ?
  • 也做systemctl enable docker开机启动
  • 另外,如果您的系统没有使用 systemd,您可以尝试使用服务包装器:service docker start
  • @DJ_Stuffy_K 我推荐你使用supervisord.org
【解决方案2】:

如果您使用的是 Mac,这可能意味着 Docker 本身没有运行。我已经重新启动了我的 Mac 并且 Docker 没有设置为在登录时自动启动。您可以将此设置为 Docker 首选项。

【讨论】:

  • 我必须启动 Docker Desktop
【解决方案3】:

如果没有任何效果,请运行:

sudo chmod +x /usr/local/bin/docker-compose

sudo docker-compose up -d

【讨论】:

  • 这一行解决了我的 grpc-web 示例问题
【解决方案4】:

如果在 WSL2 上确保 docker 服务已经启动,使用sudo service docker status 进行检查。如果它没有运行,在sudo docker-compose up之前使用命令sudo service docker start让它运行

【讨论】:

  • 有趣。我的没有提出“开始”。不过没有错误。
【解决方案5】:

有时 docker 服务会停止。您可以检查它并重新启动。如果错误是容器,通常会发生。可以修剪并重新开始。

【讨论】:

  • 请提供必要的命令来执行此操作。有关如何编写好的答案的更多信息,请参见此处:stackoverflow.com/help/how-to-answer 请详细说明“如果错误是容器,通常会发生”的意思。如果您对英语有疑问,deepl.com 可能会有所帮助:)
猜你喜欢
  • 2021-12-06
  • 2017-01-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-12-04
相关资源
最近更新 更多