Docker-Compose can't connect to Docker Daemon

后端 未结 18 935
死守一世寂寞
死守一世寂寞 2020-12-22 20:25

I am getting an error message saying I can\'t connect to the docker daemon. I have looked into other people\'s answers who have had similar issues but it hasn\'t helped. I

相关标签:
18条回答
  • 2020-12-22 21:02

    From the output of "ps aux | grep docker", it looks like docker daemon is not running. Try using below methods to see what is wrong and why docker is not starting

    1. Check the docker logs

    $ sudo tail -f /var/log/upstart/docker.log

    1. Try starting docker in debug mode

    $ sudo docker -d -D

    0 讨论(0)
  • 2020-12-22 21:03

    You should adding your user to the "docker" group with something like:

    sudo usermod -aG docker ${USER}

    0 讨论(0)
  • 2020-12-22 21:03

    In my case a have the same error when I try to docker-compose build and my solution was just add sudo

    sudo docker-compose build
    
    0 讨论(0)
  • 2020-12-22 21:03

    I found this and it seemed to fix my issue.

    GitHub Fix Docker Daemon Crash

    I changed the content of my docker-compose-deps.yml file as seen in the link. Then I ran docker-compose -f docker-compose-deps.yml up -d. Then I changed it back and it worked for some reason. I didn't have to continue the steps in the link I provided, but the first two steps fixed the issue for me.

    0 讨论(0)
  • 2020-12-22 21:06

    It appears your issue was created by an old Docker bug, where the socket file was not recreated after Docker crashed. If this is the issue, then renaming the socket file should allow it to be re-created:

    $ sudo service docker stop
    $ sudo mv /var/lib/docker /var/lib/docker.bak
    $ sudo service docker start
    

    Since this bug is fixed, most people getting the error Couldn't connect to Docker daemon are probably getting it because they are not in the docker group and don't have permissions to read that file. Running with sudo docker ... will fix that, but isn't a great solution.

    Docker can be run as a non-root user (without sudo) that has the proper group permissions. The Linux post-install docs has the details. The short version:

    $ sudo groupadd docker
    $ sudo usermod -aG docker $USER
    # Log out and log back in again to apply the groups
    $ groups  # docker should be in the list of groups for your user
    $ docker run hello-world  # Works without sudo
    

    This allows users in the docker group to run docker and docker-compose commands without sudo. Docker itself runs a root, allowing some attacks, so you still need to be careful with what containers you run. See Docker Security Documentation for more details.

    0 讨论(0)
  • 2020-12-22 21:10

    I had the same issue. After taking notes and analyzing some debugging results, finally, I solved what can be the same error. Start the service first,

    service docker start

    Don't forget to include your user to the docker group.

    0 讨论(0)
提交回复
热议问题