Docker command can't connect to Docker daemon

后端 未结 23 2995
有刺的猬
有刺的猬 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:18

    Add the user to the docker group

    • Add the docker group if it doesn't already exist:

      sudo groupadd docker

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

      sudo gpasswd -a ${USER} docker

    • Restart the Docker daemon:

      sudo service docker restart

    • Either do a newgrp docker or log out/in to activate the changes to groups.

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

    I had the same problem. Been struggling for two days to solve it.

    It only worked when I did:

    1. According to Docker's Tutorial, you need to add the Docker key if not already added using:

      $ sudo wget -qO- https://get.docker.com/gpg | sudo apt-key add -

    2. Then make sure you grant docker privileges to yourself using:

      $ sudo usermod -aG docker $USER

    Hope this helps you too.

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

    After installing docker on Ubuntu, I ran the following command:

    sudo service docker start
    

    Have you tried it?

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

    For Ubuntu 16.04

    Inside file /lib/systemd/system/docker.service change:

    ExecStart=/usr/bin/dockerd fd://
    

    with:

    ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375
    

    Inside file /etc/init.d/docker change:

    DOCKER_OPTS=
    

    with:

    DOCKER_OPTS="-H tcp://0.0.0.0:2375"
    

    and then restart your computer.

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

    As docker binds to a unix socket which is owned by root while starting up, using 'sudo' along with the docker commands will work.

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

    Had the same issue and what worked for me was:
    Checking the ownership of /var/run/docker.sock

    ls -l /var/run/docker.sock
    

    If you're not the owner then change ownership with the command

    sudo chown *your-username* /var/run/docker.sock
    

    Then you can go ahead and try executing the docker commands hassle-free :D

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