Skip to content

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

Closed

Description

@matteo-bombelli

I know that there is another issue of the same type but the other issue is closed and I tried all the solutions proposed but with no effect.

still not working:

matteo@ubuntuDockerMB:~/wordpress-docker$ sudo docker -v
Docker version 1.12.3, build 6b644ec
matteo@ubuntuDockerMB:~/wordpress-docker$ sudo docker-compose up
ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
matteo@ubuntuDockerMB:~/wordpress-docker$ sudo service docker start
start: Job is already running: docker
matteo@ubuntuDockerMB:~/wordpress-docker$ echo $DOCKER_HOST

matteo@ubuntuDockerMB:~/wordpress-docker$ DOCKER_HOST=127.0.0.1
matteo@ubuntuDockerMB:~/wordpress-docker$ echo $DOCKER_HOST
127.0.0.1
matteo@ubuntuDockerMB:~/wordpress-docker$ sudo docker-compose up
ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
matteo@ubuntuDockerMB:~/wordpress-docker$ unset DOCKER_HOST
matteo@ubuntuDockerMB:~/wordpress-docker$ sudo docker-compose up
ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
matteo@ubuntuDockerMB:~/wordpress-docker$ groups matteo
matteo : matteo adm cdrom sudo dip plugdev sambashare lpadmin docker

  • I'm part of the docker group

  • I'm using also sudo

  • The process is up

  • The DOCKER_HOST variable is unset or 127.0.0.1

  • Reconnected the user

  • Restarted the server

I think that I've tried all the possible configurations am I right?


Specs:

  • OS: Ubuntu 14.04.04 on Virtualbox on Windows 10 Home.

  • Docker version 1.12.3, build 6b644ec


Thank You!

Activity

  1. shin- commented on Nov 29, 2016

    @shin-

    Have you tried without sudo? You shouldn't need it and it could be messing things up in your case. Also, what do you see when you run docker info?

  2. harshajayaweeraXHJ commented on Nov 29, 2016

    @harshajayaweeraXHJ

    Try running dockerd or sudo dockerd if 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.

  3. matteo-bombelli commented on Dec 3, 2016

    @matteo-bombelli
    Author

    @shin- Hello! I've already done it with with sudo and also using root (sudo su).

    matteo@ubuntuDockerMB:~/wordpress-docker$ sudo docker-compose up
    ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?
    
    If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
    

    here is the operation made as root

    root@ubuntuDockerMB:/home/matteo/wordpress-docker# docker-compose up
    ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?
    
    If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
    root@ubuntuDockerMB:/home/matteo/wordpress-docker#
    

    this is the result of docker info

    root@ubuntuDockerMB:/home/matteo/wordpress-docker# docker info
    An error occurred trying to connect: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.24/info: read unix @->/var/run/docker.sock: read: connection reset by peer
    

    @harshajayaweeraXHJ

    dockerd does not work but sudo service docker start works as expected

    matteo@ubuntuDockerMB:~/wordpress-docker$ sudo dockerd
    INFO[0000] libcontainerd: new containerd process, pid: 4039
    WARN[0000] containerd: low RLIMIT_NOFILE changing to max  current=1024 max=4096
    INFO[0001] [graphdriver] using prior storage driver "aufs"
    FATA[0001] Error starting daemon: layer does not exist
    

    PS:

    @shin- & @harshajayaweeraXHJ Sorry for being late

  4. jamethy commented on Dec 22, 2016

    @jamethy

    You need to export the variable for it to be available in child processes:

    $ export DOCKER_HOST=127.0.0.1
    

    Although this doesn't completely solve your issue...

    I ran into this error because I foolishly ignored the ubuntu prerequisites.

  5. matteo-bombelli commented on Dec 23, 2016

    @matteo-bombelli
    Author

    thank you @jamethy, I,ve done just right that and i get

    matteo@ubuntuDockerMB:~/wordpress-docker-tut$ docker-compose up -d
    Traceback (most recent call last):
      File "<string>", line 3, in <module>
      File "compose/cli/main.py", line 65, in main
      File "compose/cli/main.py", line 114, in perform_command
      File "compose/cli/command.py", line 36, in project_from_options
      File "compose/cli/command.py", line 111, in get_project
      File "compose/cli/command.py", line 83, in get_client
      File "compose/cli/docker_client.py", line 74, in docker_client
      File "site-packages/docker/client.py", line 59, in __init__
      File "site-packages/docker/utils/utils.py", line 438, in parse_host
    docker.errors.DockerException: Bind address needs a port: 127.0.0.1
    docker-compose returned -1
    
  6. jorgeas80 commented on Dec 23, 2016

    @jorgeas80

    Having the same problem now, also trying to install Wordpress under docker. Tried everything, but still can' t connect. Docker daemon is not running... I'll try it again

  7. matteo-bombelli commented on Dec 23, 2016

    @matteo-bombelli
    Author

    for me the problem stays there:

    Bind address needs a port: 127.0.0.1
    

    but this number should be created by docker itself

  8. elikane commented on Dec 30, 2016

    @elikane

    I have the same problem as the original poster, and have tried all the suggested things above.

    It seems that sometimes docker "dies" and is not running, and at other times it stays running. I noticed this while trying to run the docker info command and getting an error about docker not running. Using service docker start then allowed me to run the info command. This is what I got:

    Containers: 1
    Running: 0
    Paused: 0
    Stopped: 1
    Images: 1
    Server Version: 1.12.5
    Storage Driver: aufs
    Root Dir: /var/lib/docker/aufs
    Backing Filesystem: extfs
    Dirs: 3
    Dirperm1 Supported: true
    Logging Driver: json-file
    Cgroup Driver: cgroupfs
    Plugins:
    Volume: local
    Network: host bridge overlay null
    Swarm: inactive
    Runtimes: runc
    Default Runtime: runc
    Security Options: apparmor seccomp
    Kernel Version: 4.4.0-45-generic
    Operating System: Ubuntu 16.04.1 LTS
    OSType: linux
    Architecture: x86_64
    CPUs: 24
    Total Memory: 31.42 GiB
    Name: ayn
    ID: 7TGC:G5WQ:6IYF:XWMH:XF3N:VXU7:SLZB:IHRN:T4FL:D35I:5JUA:H4S5
    Docker Root Dir: /var/lib/docker
    Debug Mode (client): false
    Debug Mode (server): false
    Registry: https://index.docker.io/v1/
    WARNING: No swap limit support
    Insecure Registries:
    127.0.0.0/8
    
  9. shin- commented on Jan 4, 2017

    @shin-

    @matteo-bombelli This error is pretty clear, you need to specify a port. Do export DOCKER_HOST=127.0.0.1:2375 instead.

  10. ippo012 commented on Jan 6, 2017

    @ippo012

    @matteo-bombelli
    I had the same issue.
    You need to restart docker.
    $ service docker restart
    I solved it with this.

  11. shashijais789 commented on Feb 1, 2017

    @shashijais789

    can anyone consolidate the solution for this problem in steps ?

  12. lalitkumarj commented on Feb 5, 2017

    @lalitkumarj

    Hi. I second this last comment, I am having the same issue.

  13. furkanmustafa commented on Feb 8, 2017

    @furkanmustafa

    I am having the same issue.

    docker ps works.

    docker-compose build (with version 2) works!

    docker-compose build (with version 3) gives this error :/

  14. 198 remaining items

  15. Ivor commented on Feb 11, 2021

    @Ivor

    Ubuntu 20.0.4 LTS

    Initially with this command

    docker-compose up
    

    I got the same error.

    Then I saw the comment about changing the permissions on docker.sock
    Then this worked:

    sudo docker-compose up
    

    Then I saw the comment about Ubuntu not adding the user to the docker group, so I
    returned the docker.sock file to its original permissions:

    sudo chmod 660 /var/run/docker.sock
    

    and then I did

    sudo groupadd docker
    sudo usermod -aG docker $USER
    sudo reboot
    

    and then this worked:

    docker-compose up
    
  16. dmytro-kerest commented on Feb 17, 2021

    @dmytro-kerest

    it might help someone someday.
    install docker-compose tool from docker website instructions and NOT from the repo of your distribution - in most cases it is outdated.
    I have trie everything from the list here and the only thing that did work is installing latest docker-compose

  17. aguschapuis commented on Feb 25, 2021

    @aguschapuis

    Try with sudo chmod 666 /var/run/docker.sock

  18. Taranchul commented on Feb 25, 2021

    @Taranchul

    Try with sudo chmod 666 /var/run/docker.sock

    This makes the file writable by every user which is a potential security risk in a system directory. That should only be considered as a last resort after trying the safer solution posted here before:

    sudo groupadd docker
    sudo usermod -aG docker $USER
    sudo reboot
    
  19. MUKESHBADIGINENI commented on Mar 22, 2021

    @MUKESHBADIGINENI

    I tried the following process, it's working perfectly in my case.....!!

    1. Check "hostname" in your script.
    2. Run the command with sudo.
      sudo docker-compose up -d
    3. Once the image files downloaded and extracted it will start the network.
      image
  20. klongbeard commented on Apr 21, 2021

    @klongbeard

    hey i'm late to the party I know but for anyone who gets this error on a live server just log out and back in again. When you add your user to the docker group you need to reload your terminal to get the updated permissions.

  21. facundopadilla commented on May 7, 2021

    @facundopadilla

    newgrp docker

    This work's me fine !

  22. asmexcaliburwoods commented on Aug 12, 2021

    @asmexcaliburwoods

    sudo chown -Rv someuser.someuser ~someuser/ helped me to fix. someuser is the user i develop under and run docker-compose under it, too.

  23. vigi04 commented on Aug 25, 2021

    @vigi04

    Sometimes, the error comes when the Image name contains uppercase characters..

    service-name:
    image: Abcd/Xyz
    build: ..

    corrected compose file

    service-name:
    image: abcd/xyz
    build: ..

  24. maxshuang commented on Sep 6, 2021

    @maxshuang

    Try running dockerd or sudo dockerd if 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.

    work for me

  25. hannwei commented on Sep 11, 2021

    @hannwei

    "sudo docker-compose up" will most likely solve the problem.

    But for people who do not want to sudo on docker-compose for security reasons, this may help :

    sudo chgrp -R docker /var/run/docker

    No idea which file really needs it. But changing the group of all those docker files probably does not cause harm. That is a docker group anyway.

  26. ahmedyounes commented on Jan 23, 2022

    @ahmedyounes

    in my case i was mentioning image in docker-compose.yml with variables im not using anymore
    image: "${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA}"

  27. Railkhayrullin commented on Apr 15, 2022

    @Railkhayrullin

    If nothing helps, add to the folder with docker-compose.yml file .env with variable values from docker-compose.yml.

    example .env file:

    # CI-CD
    CI_REGISTRY_IMAGE=registry.gitlab.example.com/project
    CI_COMMIT_REF_SLUG=dev
    CI_ENVIRONMENT_NAME=dev
    
    # server
    DJANGO_SETTINGS_MODULE=server.core.settings.dev
    SECRET_KEY=dfghsdhjlsjdhlkjgfh57f5gjhdghjk4447789677jhlhgl
    DEBUG=1
    
  28. franco148 commented on Dec 8, 2022

    @franco148

    I have no idea why, but what fixed it for me was removing the following line from my docker-compose .env file:

    DOCKER_HOST=tcp://localhost:2375
    

    For some reason this is true, in my linux environment I had the same issue because there was DOCKER_HOST=tcp://localhost:2375 configured as environment variable. Removing it fixed the issue.

  29. k-caps commented on Aug 26, 2024

    @k-caps

    Just to add my own 2 cents:
    In my case the problem was an autogenerated .env file which used the git branch name as the docker tag. The branch name was 134 characters long, and docker tags can only be up to 128.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions