0

Similar to other questions (see here and here) I'm getting the following error, both ways, with sudo or without:

/snap/docker/2343/lib/python3.6/site-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release.
  from cryptography.hazmat.backends import default_backend
Traceback (most recent call last):
  File "/snap/docker/2343/lib/python3.6/site-packages/urllib3/connectionpool.py", line 710, in urlopen
    chunked=chunked,
  File "/snap/docker/2343/lib/python3.6/site-packages/urllib3/connectionpool.py", line 398, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/snap/docker/2343/usr/lib/python3.6/http/client.py", line 1285, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/snap/docker/2343/usr/lib/python3.6/http/client.py", line 1331, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/snap/docker/2343/usr/lib/python3.6/http/client.py", line 1280, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/snap/docker/2343/usr/lib/python3.6/http/client.py", line 1046, in _send_output
    self.send(msg)
  File "/snap/docker/2343/usr/lib/python3.6/http/client.py", line 984, in send
    self.connect()
  File "/snap/docker/2343/lib/python3.6/site-packages/docker/transport/unixconn.py", line 30, in connect
    sock.connect(self.unix_socket)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/snap/docker/2343/lib/python3.6/site-packages/requests/adapters.py", line 450, in send
    timeout=timeout
  File "/snap/docker/2343/lib/python3.6/site-packages/urllib3/connectionpool.py", line 788, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/snap/docker/2343/lib/python3.6/site-packages/urllib3/util/retry.py", line 550, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/snap/docker/2343/lib/python3.6/site-packages/urllib3/packages/six.py", line 769, in reraise
    raise value.with_traceback(tb)
  File "/snap/docker/2343/lib/python3.6/site-packages/urllib3/connectionpool.py", line 710, in urlopen
    chunked=chunked,
  File "/snap/docker/2343/lib/python3.6/site-packages/urllib3/connectionpool.py", line 398, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/snap/docker/2343/usr/lib/python3.6/http/client.py", line 1285, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/snap/docker/2343/usr/lib/python3.6/http/client.py", line 1331, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/snap/docker/2343/usr/lib/python3.6/http/client.py", line 1280, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/snap/docker/2343/usr/lib/python3.6/http/client.py", line 1046, in _send_output
    self.send(msg)
  File "/snap/docker/2343/usr/lib/python3.6/http/client.py", line 984, in send
    self.connect()
  File "/snap/docker/2343/lib/python3.6/site-packages/docker/transport/unixconn.py", line 30, in connect
    sock.connect(self.unix_socket)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionRefusedError(111, 'Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/snap/docker/2343/lib/python3.6/site-packages/docker/api/client.py", line 214, in _retrieve_server_version
    return self.version(api_version=False)["ApiVersion"]
  File "/snap/docker/2343/lib/python3.6/site-packages/docker/api/daemon.py", line 181, in version
    return self._result(self._get(url), json=True)
  File "/snap/docker/2343/lib/python3.6/site-packages/docker/utils/decorators.py", line 46, in inner
    return f(self, *args, **kwargs)
  File "/snap/docker/2343/lib/python3.6/site-packages/docker/api/client.py", line 237, in _get
    return self.get(url, **self._set_request_timeout(kwargs))
  File "/snap/docker/2343/lib/python3.6/site-packages/requests/sessions.py", line 542, in get
    return self.request('GET', url, **kwargs)
  File "/snap/docker/2343/lib/python3.6/site-packages/requests/sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "/snap/docker/2343/lib/python3.6/site-packages/requests/sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "/snap/docker/2343/lib/python3.6/site-packages/requests/adapters.py", line 501, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionRefusedError(111, 'Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/snap/docker/2343/bin/docker-compose", line 33, in <module>
    sys.exit(load_entry_point('docker-compose==1.29.2', 'console_scripts', 'docker-compose')())
  File "/snap/docker/2343/lib/python3.6/site-packages/compose/cli/main.py", line 81, in main
    command_func()
  File "/snap/docker/2343/lib/python3.6/site-packages/compose/cli/main.py", line 200, in perform_command
    project = project_from_options('.', options)
  File "/snap/docker/2343/lib/python3.6/site-packages/compose/cli/command.py", line 70, in project_from_options
    enabled_profiles=get_profiles_from_options(options, environment)
  File "/snap/docker/2343/lib/python3.6/site-packages/compose/cli/command.py", line 153, in get_project
    verbose=verbose, version=api_version, context=context, environment=environment
  File "/snap/docker/2343/lib/python3.6/site-packages/compose/cli/docker_client.py", line 43, in get_client
    environment=environment, tls_version=get_tls_version(environment)
  File "/snap/docker/2343/lib/python3.6/site-packages/compose/cli/docker_client.py", line 170, in docker_client
    client = APIClient(use_ssh_client=not use_paramiko_ssh, **kwargs)
  File "/snap/docker/2343/lib/python3.6/site-packages/docker/api/client.py", line 197, in __init__
    self._version = self._retrieve_server_version()
  File "/snap/docker/2343/lib/python3.6/site-packages/docker/api/client.py", line 222, in _retrieve_server_version
    f'Error while fetching server API version: {e}'
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', ConnectionRefusedError(111, 'Connection refused'))

Docker-Compose version is 1.29.2, build unknown.

Docker-Desktop v4.16.2 is running.

The docker-compose file is the sample from the installation guide:

services:
  opensearch-node1: # This is also the hostname of the container within the Docker network (i.e. https://opensearch-node1/)
    image: opensearchproject/opensearch:latest # Specifying the latest available image - modify if you want a specific version
    container_name: opensearch-node1
    environment:
      - cluster.name=opensearch-cluster # Name the cluster
      - node.name=opensearch-node1 # Name the node that will run in this container
      - discovery.seed_hosts=opensearch-node1,opensearch-node2 # Nodes to look for when discovering the cluster
      - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 # Nodes eligible to serve as cluster manager
      - bootstrap.memory_lock=true # Disable JVM heap memory swapping
      - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM
    ulimits:
      memlock:
        soft: -1 # Set memlock to unlimited (no soft or hard limit)
        hard: -1
      nofile:
        soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
        hard: 65536
    volumes:
      - opensearch-data1:/usr/share/opensearch/data # Creates volume called opensearch-data1 and mounts it to the container
    ports:
      - 9200:9200 # REST API
      - 9600:9600 # Performance Analyzer
    networks:
      - opensearch-net # All of the containers will join the same Docker bridge network
  opensearch-node2:
    image: opensearchproject/opensearch:latest # This should be the same image used for opensearch-node1 to avoid issues
    container_name: opensearch-node2
    environment:
      - cluster.name=opensearch-cluster
      - node.name=opensearch-node2
      - discovery.seed_hosts=opensearch-node1,opensearch-node2
      - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2
      - bootstrap.memory_lock=true
      - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    volumes:
      - opensearch-data2:/usr/share/opensearch/data
    networks:
      - opensearch-net
  opensearch-dashboards:
    image: opensearchproject/opensearch-dashboards:latest # Make sure the version of opensearch-dashboards matches the version of opensearch installed on other nodes
    container_name: opensearch-dashboards
    ports:
      - 5601:5601 # Map host port 5601 to container port 5601
    expose:
      - "5601" # Expose port 5601 for web access to OpenSearch Dashboards
    environment:
      OPENSEARCH_HOSTS: '["https://opensearch-node1:9200","https://opensearch-node2:9200"]' # Define the OpenSearch nodes that OpenSearch Dashboards will query
    networks:
      - opensearch-net

volumes:
  opensearch-data1:
  opensearch-data2:

networks:
  opensearch-net:

Docker-Service (version 23.0.1, build a5ee5b1) is both, started and enabled.

● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2023-02-15 16:21:30 CET; 3min 6s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 115111 (dockerd)
      Tasks: 13
     Memory: 24.5M
        CPU: 433ms
     CGroup: /system.slice/docker.service
             └─115111 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Feb 15 16:21:29 pb-hp dockerd[115111]: time="2023-02-15T16:21:29.718609786+01:00" level=info msg="[core] [Channel #4] Channel Connectivity change to READY" module=grpc
Feb 15 16:21:29 pb-hp dockerd[115111]: time="2023-02-15T16:21:29.805482945+01:00" level=info msg="[graphdriver] using prior storage driver: zfs"
Feb 15 16:21:29 pb-hp dockerd[115111]: time="2023-02-15T16:21:29.821299671+01:00" level=info msg="Loading containers: start."
Feb 15 16:21:29 pb-hp dockerd[115111]: time="2023-02-15T16:21:29.944847466+01:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a >
Feb 15 16:21:29 pb-hp dockerd[115111]: time="2023-02-15T16:21:29.979883193+01:00" level=info msg="Loading containers: done."
Feb 15 16:21:29 pb-hp dockerd[115111]: time="2023-02-15T16:21:29.991791851+01:00" level=info msg="Docker daemon" commit=bc3805a graphdriver=zfs version=23.0.1
Feb 15 16:21:29 pb-hp dockerd[115111]: time="2023-02-15T16:21:29.991880201+01:00" level=info msg="Daemon has completed initialization"
Feb 15 16:21:30 pb-hp dockerd[115111]: time="2023-02-15T16:21:30.013044715+01:00" level=info msg="[core] [Server #7] Server created" module=grpc
Feb 15 16:21:30 pb-hp systemd[1]: Started Docker Application Container Engine.
Feb 15 16:21:30 pb-hp dockerd[115111]: time="2023-02-15T16:21:30.023604797+01:00" level=info msg="API listen on /run/docker.sock"

I can see that a container that I imported in Docker-Desktop is running:

CONTAINER ID   IMAGE               COMMAND                  CREATED       STATUS       PORTS                NAMES
bd0f564c0243   docker101tutorial   "/docker-entrypoint.…"   2 hours ago   Up 2 hours   0.0.0.0:80->80/tcp   docker-tutorial

According to answers to similar problems, I've tried the following already:

  • source ~/.bashrc (see here)
  • sudo groupadd docker plus sudo usermod -aG docker $USER (see here). groups is confirming that I am in the group docker.
  • sudo gpasswd -a $USER docker plus newgrp docker - doing the same as above, just to make sure everything has been tried (see here)
  • sudo chmod 666 /var/run/docker.sock (potentially unsafe, but it's only my development machine) (see here)
  • sudo service docker restart (sudo systemctl status docker.service in my case) (see here)
  • "Enable Docker Compose V1/V2 compatibility mode" is checked in Docker-Desktop (see here) though I guess this is unnecessary because of the initial line version: '3'.

I also wanted to set "WSL Integration" as recommended here but the option is not present in my version of Docker Desktop. By the way, the same error appears when I say: $ docker-compose -f /home/bo/git/gokb/docker-compose-default.yml down.

How can I make the error disappear and compose?

I am a very-newbie to docker.

philburns
  • 310
  • 4
  • 18

0 Answers0