Docker command can't connect to Docker daemon

后端 未结 23 2993
有刺的猬
有刺的猬 2020-12-02 04:01

I want to make a move to Docker, so I\'ve just started to mess around with it. I\'ve installed Docker on a VirtualBox Ubuntu 15.10 (Wily Werewolf) installation and as sugges

相关标签:
23条回答
  • 2020-12-02 04:28

    Giving non-root access - from docker

    Add the docker group if it doesn't already exist.

    $ sudo groupadd docker
    

    Add the connected user "${USER}" to the docker group.

    Change the user name to match your preferred user.

    You may have to logout and log back in again for this to take effect.

    $ sudo gpasswd -a ${USER} docker
    

    Restart the Docker daemon.

    $ sudo service docker restart
    
    0 讨论(0)
  • 2020-12-02 04:29

    For OSX:

    After opening docker and starting the 'default' machine via the Quickstart Terminal (https://docs.docker.com/engine/installation/mac/), you try docker commands and get this "can't connect to docker daemon" message, it turns out you need some env variables set:

    eval "$(docker-machine env default)"

    Then try it out with docker run hello-world to see if everything is peachy.

    0 讨论(0)
  • 2020-12-02 04:30

    This question is currently number 3 on a Google search. After doing some research into solving this problem on my Linux system I thought I would write this answer. The original post states the problem is on Ubuntu but I also experienced the issue using Fedora. With that in mind, here is what I did to fix the problem.

    On Fedora 22

    Installing Docker:

    $> curl -fsSL https://get.docker.com/ | sh
    

    After installing Docker:

    A user needs to be added to the docker group.

    $> sudo usermod -aG docker
    

    The docker daemon needs to be started

    $> sudo service docker start
    

    You can set the daemon to start at boot

    $> sudo chkconfig docker on
    

    You can verify the docker service is running

    $> service docker status
    

    And one last final check

    $> docker run hello-world
    
    0 讨论(0)
  • 2020-12-02 04:31
    1. I also had the same issue. The problem was in sockets allocated to docker-daemon and docker-client.
    2. First, permission was not set for the docker-client on docker.sock You can set it using "sudo usermod -aG docker $USER"
    3. Then check your bash file where the docker-client is running, For me it was on 0.0.0.0:2375, while docker-daemon was running on unix socket.(It was set in the configuration file of dockerd).
    4. Just comment the bash-line and it'll work fine.
    5. But if you want to make it work on TCP port instead of unix socket, change the configuration file of dockerd and set it on 0.0.0.0.2375 and keep the line in bash as it is if present or set it to 0.0.0.0:2375.
    0 讨论(0)
  • 2020-12-02 04:36

    Usually, the following command does the trick:

    sudo service docker restart
    

    This, instead of docker start for the cases where Docker seems to already be running.

    If that works then, as suggested and in another answer and on this GitHub issue, if you haven't added yourself in the docker group do it by running:

    sudo usermod -aG docker <your-username> 
    

    And you're most likely good to go.


    As for anybody else bumping into this, in some OS's docker doesn't start right after you install it and, as a result, the same can't connect to daemon message appears. In this case you can first verify that Docker is indeed not running by checking the status of your docker service by executing:

    sudo service docker status
    

    If the output looks something like: docker stop/waiting instead of docker start/running, process 15378 then it obviously means Docker is not active. In this case make sure you start it with:

    sudo service docker start
    

    And, as before, you'll most likely be good to go.

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