compose icon indicating copy to clipboard operation
compose copied to clipboard

Couldn't connect to Docker daemon at http+unix://var/run/docker.sock - is it running?

Open rept opened this issue 11 years ago • 131 comments

I tried everything in this thread: https://github.com/docker/compose/issues/88

Still no luck.

rept@temponia:~/passenger$ netstat -ant  |grep 4243
tcp        0      0 127.0.0.1:4243          0.0.0.0:*               LISTEN     
rept@temponia:~/passenger$ echo $DOCKER_HOST
tcp://localhost:4243
rept@temponia:~/passenger$ sudo docker-compose build db uses an image, skipping
Building web...
Couldn't connect to Docker daemon at http+unix://var/run/docker.sock - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

This is the version:

rept@temponia:~/passenger$ sudo docker version
Client version: 1.0.1
Client API version: 1.12
Go version (client): go1.2.1
Git commit (client): 990021a
Server version: 1.0.1
Server API version: 1.12
Go version (server): go1.2.1
Git commit (server): 990021a

Any ideas? I also tried installing fig which works right away without any problem...

rept avatar Mar 29 '15 21:03 rept

I get the same error message when I run docker. It is solved by adding myself to the user group 'docker'

Try to run the following command to add yourself to the group usermod -aG docker ${USER}

Or you can run the following command to find out what groups you belong to groups $USER

leoyuholo avatar May 15 '15 03:05 leoyuholo

Looks like docker-compose is disregarding the $DOCKER_HOST env var here, because it's trying to connect to the socket in stead of the 127.0.0.1 address.

thaJeztah avatar May 26 '15 08:05 thaJeztah

same issue here

francescolofranco-dev avatar Aug 11 '15 21:08 francescolofranco-dev

I encountered same error message just now, that time my laptop WiFi is off without wired connection. I enable WiFi and connected to home wireless network then problem solved.

tylerteh avatar Aug 20 '15 13:08 tylerteh

You can try the 5.0.3 (prebuild) at https://www.virtualbox.org/wiki/Testbuilds ? It's fix this issue for me.

comxd avatar Aug 28 '15 14:08 comxd

i had that problem using docker in my mac, but it got solved one i ran the compose command without sudo, so it seems it is a user issue,

dagisus avatar Sep 06 '15 21:09 dagisus

Soleved for me too with sudo command

vkeziah avatar Sep 18 '15 09:09 vkeziah

@rept are you still having this issue? The docker version you reported is over a year old now, which is, well, pre-historic in docker terms :)

I wonder if this issue should be kept open because it's now collecting all kind of possible reasons the daemon cannot be reached (I don't mean this in a bad way; thanks everyone for suggesting solutions, it is appreciated)

thaJeztah avatar Sep 18 '15 09:09 thaJeztah

I did a new installation on a completely different machine and it's working now. So you van close it.

rept avatar Sep 18 '15 09:09 rept

Thanks, @rept, and good to hear it was resolved!

thaJeztah avatar Sep 18 '15 21:09 thaJeztah

I get

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

too everytime I activate tty: true or stdin_open: true in docker-compose.yml and running docker-compose up.

Can it be related?

Docker version 1.9.1, build a34a1d5
docker-compose version 1.5.2, build 7240ff3

alexanderadam avatar Jan 04 '16 15:01 alexanderadam

I just solved my problem running the "docker-compose run ..." command with sudo.

romerobrjp avatar Jan 19 '16 13:01 romerobrjp

I ran into this when running docker compose up -d during vagrant up. User vagrant has been added to group docker but the above error appears when running it without sudo. It works later on if one logs in as user vagrant but fails during provisioning so it has something to do with env variables?

docker-compose version: 1.4.1

jurajseffer avatar Feb 01 '16 14:02 jurajseffer

Simple solution: sudo docker-compose up

cloojure avatar Feb 24 '16 05:02 cloojure

I ran to same issue with:

[root@c910f05c01bc07 xcat-docker]# docker-compose version
docker-compose version 1.6.2, build 4d72027
docker-py version: 1.7.2
CPython version: 2.7.9
OpenSSL version: OpenSSL 1.0.1e 11 Feb 2013

docker version:

[root@c910f05c01bc07 xcat-docker]# docker version
Client:
 Version:      1.10.2
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   c3959b1
 Built:        Mon Feb 22 16:16:33 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.10.2
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   c3959b1
 Built:        Mon Feb 22 16:16:33 2016
 OS/Arch:      linux/amd64

immarvin avatar Mar 10 '16 06:03 immarvin

That is a workaround not a solution, right?

mashimom avatar Mar 11 '16 17:03 mashimom

I still often face with this

sergeyklay avatar Mar 11 '16 17:03 sergeyklay

This is not a compose issue. If you can't connect to the docker daemon from compose there are a few likely causes:

  • you forgot to export the DOCKER_ env variables, which is often done by running eval $(docker-machine env default)
  • there is a network problem between you and the remote docker host (if you're running on a cloud provider)
  • there is a problem with the docker daemon running in the Virtualbox VM
  • your user doesn't have access to the docker daemon socket because of permissions (if you're running on a linux host). The solution is to sudo or fix the permissions.

These aren't problems that can be solved by compose.

There is an issue with tty, which is ticketed here: #3106

dnephin avatar Mar 11 '16 21:03 dnephin

I can confirm: This is not a docker-compose issue.

If it helps: I came across the same issue (Couldn't connect...) on a Ubuntu host. Running sudo systemctl status docker.service -l showed the "real" issue. The solution in my case was to remove all files in "/var/lib/docker/network/files/" and restart the docker service.

madflow avatar Mar 12 '16 17:03 madflow

hi @dnephin @madflow , I think this is a docker-compose issue.

Since with the same docker image and docker network, the container can be started up successfully with

 sudo docker run -it --privileged=true  --hostname=xcatmn --name=xcatmn --add-host="xcatmn.clusers.com xcatmn:10.5.107.101" --volume /docker/xcatdata/:/install --net=subnet1 --ip=10.5.107.101  xcat/xcat-ubuntu-x86_64

but failed with "docker-compose up". The docker-compose.yml is right the equivalent of the options and arguments of "docker run":

[root@c910f05c01bc07 xcat-docker]# docker-compose config
networks:
  default:
    external:
      name: subnet1
    external_name: subnet1
services:
  xcatmn:
    container_name: xcatmn
    extra_hosts:
      xcatmn.clusers.com xcatmn: 10.5.107.101
    hostname: xcatmn
    image: xcat/xcat-ubuntu-x86_64
    networks:
      default:
        ipv4_address: 10.5.107.101
    privileged: true
    stdin_open: true
    tty: true
    volumes:
    - /docker/xcatdata:/install:rw
version: '2.0'
volumes: {}

The docker and compose version info:

[root@c910f05c01bc07 xcat-docker]# docker version
Client:
 Version:      1.10.2
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   c3959b1
 Built:        Mon Feb 22 16:16:33 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.10.2
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   c3959b1
 Built:        Mon Feb 22 16:16:33 2016
 OS/Arch:      linux/amd64
[root@c910f05c01bc07 xcat-docker]# docker-compose version
docker-compose version 1.7.0dev, build 99d68be
docker-py version: 1.8.0-dev
CPython version: 2.7.9
OpenSSL version: OpenSSL 1.0.1e 11 Feb 2013

immarvin avatar Mar 13 '16 02:03 immarvin