Docker command can't connect to Docker daemon

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

    For the ones who already tried restarting your machine, unsetting the environment variable DOCKER_HOST as told in the docker env documentation and all the rest just try to go with the

    sudo service docker restart
    

    Only this did the trick for me even after restarting the machine.

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

    For Ubuntu:
    Happened with me when I updated docker.
    You need to unmask the service and socket and then restart the service.

    Following worked for me:

    systemctl unmask docker.service
    systemctl unmask docker.socket
    systemctl start docker.service
    

    What happend behind the scenes
    systemd also has the ability to mark a unit as completely unstartable, automatically or manually, by linking it to /dev/null. This is called masking the unit, and is possible with the mask command.

    sudo systemctl mask docker.service
    

    You can check the list of masked services using:

    sudo systemctl list-unit-files
    

    To enable auto/manual start of service you need to unmask it using:

    sudo sytemctl unmask docker.service
    

    Now the service will be enabled as shown below

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

    Tested in Ubuntu 16.04

    # Create the docker group and add your user to the docker group
    groupadd docker
    usermod -aG docker $USER
    newgrp docker
    
    # Configure docker service to be exposed
    mkdir -p /etc/systemd/system/docker.service.d
    echo -e '[Service]\nExecStart=\nExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2376' >> /etc/systemd/system/docker.service.d/override.conf
    
    # restart service
    systemctl daemon-reload
    service docker restart
    
    0 讨论(0)
  • 2020-12-02 04:14

    You need to add your current user to the docker group as follows:

    sudo usermod -aG docker $(whoami)
    

    then logout & login again into the system or restart the system. test by docker version

    for further info how to install docker-engine follow docker documentation

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

    Try to use "sudo" with the command you are running.

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

    After install everything and start the service, try close your terminal and open it again, then try pull your image

    Edit

    I also had this issue again, if the solution above won't worked, try this solution that is the command bellow

    sudo mv /var/lib/docker/network/files/ /tmp/dn-bak
    

    Considerations

    If command above works you probably are with network docker problems, anyway this resolves it, to confirm that, see the log with the command bellow

    tail -5f /var/log/upstart/docker.log
    

    If the output have something like that

    FATA[0000] Error starting daemon: Error initializing network controller: could not delete the default bridge network: network bridge has active endpoints 
    /var/run/docker.sock is up
    

    You really are with network problems, however I do not know yet if the next time you restart(update, 2 months no issue again) your OS will get this problem again and if it is a bug or installation problem

    My docker version

    Client:
     Version:      1.9.1
     API version:  1.21
     Go version:   go1.4.2
     Git commit:   a34a1d5
     Built:        Fri Nov 20 13:12:04 UTC 2015
     OS/Arch:      linux/amd64
    
    Server:
     Version:      1.9.1
     API version:  1.21
     Go version:   go1.4.2
     Git commit:   a34a1d5
     Built:        Fri Nov 20 13:12:04 UTC 2015
     OS/Arch:      linux/amd64
    
    0 讨论(0)
提交回复
热议问题