Can't connect to docker from docker-compose

前端 未结 24 2033
说谎
说谎 2020-12-07 10:14

I installed docker-machine 0.1.0 and docker-compose 1.1.0 on Mac OS 10.8.5.
Docker-machine is running normally and able to connect by docker-machine ssh.



        
相关标签:
24条回答
  • 2020-12-07 10:38

    $sudo docker-compose up

    I did follow the steps as it is in the above answer to add $USER to group docker. i didn't want to add a new group docker because in my docker installation a group named docker automatically created.

    Docker CE is installed and running. The docker group is created but no users are added to it. You need to use sudo to run Docker commands. Continue to Linux postinstall to allow non-privileged users to run Docker commands and for other optional configuration steps.

    but using docker-compose up didn't work either. It gave the same previous error. So in my case(Ubuntu 18.10) sudo docker-compose up fixed the issue.

    ps: @Tiw thanks for the advice.

    0 讨论(0)
  • 2020-12-07 10:39

    For me, I started upgrading Docker and cancelled midway. I didn't notice that Docker was not running (if it was, there is an icon at the top nav bar of my Macbook, by the battery remaining, time, etc). Once I launched it, and finished the upgrade, docker-compose up worked again!

    0 讨论(0)
  • 2020-12-07 10:42

    Try running dockerd or sudo dockerdif required first to start daemon. If you start dockerd with sudo you may want to run docker-compose up with sudo also. otherwise it's fine.

    Working solution from https://github.com/docker/compose/issues/4181

    0 讨论(0)
  • 2020-12-07 10:44

    When you get an Error:

    ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

    The Solution would be:

    1. First, try verifying Docker Service is Up and Running as expected on your remote/local machine:sudo service docker status

      if Not - run sudo service docker start or sudo systemctl start docker (depends on some linux versions, see Docker get started instructions).

    2. Second, start docker as sudo sudo docker-compose up

    0 讨论(0)
  • 2020-12-07 10:45

    I have resolved the issue using following steps

    $ sudo service docker status
    $ sudo service docker start
    $ sudo docker-compose up
    

    now docker-compose up is working

    0 讨论(0)
  • 2020-12-07 10:45

    The following worked for me, I'm not sure what part did the trick:

    julian:project$ sudo service docker status
    julian:varys$ sudo service docker status                                                                                                                                                                                
    ● docker.service - Docker Application Container Engine
       Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
       Active: active (running) since Wed 2020-07-15 01:21:16 UTC; 24min ago
         Docs: https://docs.docker.com
     Main PID: 6762 (dockerd)
        Tasks: 25
       CGroup: /system.slice/docker.service
               └─6762 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
    
    julian:project$ export DOCKER_HOST=unix:///run/containerd/containerd.sock
    
    julian:project$ sudo groupadd docker
    groupadd: group 'docker' already exists
    julian:project$ sudo gpasswd -a $USER docker
    Adding user ubuntu to group docker
    julian:project$ newgrp docker
    
    julian:project$ ls -ln /var/run/ | grep docker
    drwx------  5   0   0  120 Jul 15 01:10 docker
    -rw-r--r--  1   0   0    4 Jul 15 01:10 docker.pid
    srw-rw----  1   0 999    0 Jul 15 01:10 docker.sock
    
    julian:project$ sudo rm /var/run/docker.sock                                                                                                                                                                                            
    julian:project$ sudo rm /var/run/docker.pid
    
    julian:project$ sudo service docker restart  
    
    0 讨论(0)
提交回复
热议问题