Returning python error while running docker-compose.

huangapple go评论96阅读模式
英文:

Returning python error while running docker-compose

问题

我正在使用 Fedora Linux 38,Docker 版本是 Docker version 24.0.2, build cb74dfc
尝试通过 docker-compose 运行我的 Golang 代码,但出现了 Python 错误日志。首先我运行了 sudo systemctl start docker,然后查看状态 sudo systemctl status docker
接下来运行 sudo dockerd --debug 出现了错误信息。
然后我进入我的工作目录并运行 docker-compose up -d,出现了如下错误。我尝试重新安装 docker-compose,但仍然出错。

英文:

I am using Fedora Linux 38, and Docker version is Docker version 24.0.2, build cb74dfc.
Trying to run my Golang code through docker-compose, it giving error with python error log

First I ran sudo systemctl start docker, and then see status sudo systemctl status docker

● docker.service - Docker Application Container Engine
     Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf
     Active: active (running) since Thu 2023-07-06 15:36:12 WITA; 1h 28min ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 6250 (dockerd)
      Tasks: 19
     Memory: 25.1M
        CPU: 1.129s
     CGroup: /system.slice/docker.service
             └─6250 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Jul 06 15:36:11 fedora dockerd[6250]: time="2023-07-06T15:36:11.945573688+08:00" level=info msg="Loading containers: start."
Jul 06 15:36:11 fedora dockerd[6250]: time="2023-07-06T15:36:11.951059455+08:00" level=info msg="Firewalld: docker zone already exists, returning"
Jul 06 15:36:12 fedora dockerd[6250]: time="2023-07-06T15:36:12.201788778+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Jul 06 15:36:12 fedora dockerd[6250]: time="2023-07-06T15:36:12.219682126+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Jul 06 15:36:12 fedora dockerd[6250]: time="2023-07-06T15:36:12.575897504+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Jul 06 15:36:12 fedora dockerd[6250]: time="2023-07-06T15:36:12.693718363+08:00" level=info msg="Loading containers: done."
Jul 06 15:36:12 fedora dockerd[6250]: time="2023-07-06T15:36:12.770247971+08:00" level=info msg="Docker daemon" commit=659604f graphdriver=overlay2 version=24.0.2
Jul 06 15:36:12 fedora dockerd[6250]: time="2023-07-06T15:36:12.770335275+08:00" level=info msg="Daemon has completed initialization"
Jul 06 15:36:12 fedora dockerd[6250]: time="2023-07-06T15:36:12.808876169+08:00" level=info msg="API listen on /run/docker.sock"
Jul 06 15:36:12 fedora systemd[1]: Started docker.service - Docker Application Container Engine.

Then sudo dockerd --debug got

INFO[2023-07-06T17:09:52.227973747+08:00] Starting up                                  
failed to start daemon, ensure docker is not running or delete /var/run/docker.pid: process with PID 6250 is still running

After that I go to my working directory and run docker-compose up -d and it return error like this

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 398, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib64/python3.11/http/client.py", line 1286, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib64/python3.11/http/client.py", line 1332, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.11/http/client.py", line 1281, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.11/http/client.py", line 1041, in _send_output
    self.send(msg)
  File "/usr/lib64/python3.11/http/client.py", line 979, in send
    self.connect()
  File "/usr/lib/python3.11/site-packages/docker/transport/unixconn.py", line 30, in connect
    sock.connect(self.unix_socket)
PermissionError: [Errno 13] Permission denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urllib3/util/retry.py", line 550, in increment
    raise six.reraise(type(error), error, _stacktrace)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urllib3/packages/six.py", line 718, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 398, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib64/python3.11/http/client.py", line 1286, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib64/python3.11/http/client.py", line 1332, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.11/http/client.py", line 1281, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.11/http/client.py", line 1041, in _send_output
    self.send(msg)
  File "/usr/lib64/python3.11/http/client.py", line 979, in send
    self.connect()
  File "/usr/lib/python3.11/site-packages/docker/transport/unixconn.py", line 30, in connect
    sock.connect(self.unix_socket)
urllib3.exceptions.ProtocolError: ('Connection aborted.', PermissionError(13, 'Permission denied'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/docker/api/client.py", line 214, in _retrieve_server_version
    return self.version(api_version=False)["ApiVersion"]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/docker/api/daemon.py", line 181, in version
    return self._result(self._get(url), json=True)
                        ^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/docker/utils/decorators.py", line 46, in inner
    return f(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/docker/api/client.py", line 237, in _get
    return self.get(url, **self._set_request_timeout(kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/requests/adapters.py", line 547, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', PermissionError(13, 'Permission denied'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/docker-compose", line 33, in <module>
    sys.exit(load_entry_point('docker-compose==1.29.2', 'console_scripts', 'docker-compose')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/compose/cli/main.py", line 81, in main
    command_func()
  File "/usr/lib/python3.11/site-packages/compose/cli/main.py", line 200, in perform_command
    project = project_from_options('.', options)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/compose/cli/command.py", line 60, in project_from_options
    return get_project(
           ^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/compose/cli/command.py", line 152, in get_project
    client = get_client(
             ^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/compose/cli/docker_client.py", line 41, in get_client
    client = docker_client(
             ^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/compose/cli/docker_client.py", line 170, in docker_client
    client = APIClient(use_ssh_client=not use_paramiko_ssh, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/docker/api/client.py", line 197, in __init__
    self._version = self._retrieve_server_version()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/docker/api/client.py", line 221, in _retrieve_server_version
    raise DockerException(
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', PermissionError(13, 'Permission denied'))

I am trying to reinstall docker-compose but it still error

答案1

得分: 1

卸载,并尝试官方的 docker-ce
https://docs.docker.com/engine/install/fedora/

英文:

uninstall, and try official docker-ce
https://docs.docker.com/engine/install/fedora/

答案2

得分: 0

删除 .pid 文件的命令:

rm /var/run/docker.pid

重启 Docker:

sudo systemctl restart docker
英文:

It means the previous PID file of Docker service is still available, so the Docker service it can't start the service because one process id is already present. To prevent this error, you have to remove the previous PID file and then try to start your service.

Delete the .pid file with the command:

rm /var/run/docker.pid

Restart Docker:

sudo systemctl restart docker

huangapple
  • 本文由 发表于 2023年7月6日 17:12:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76627256.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定