New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
rept opened this Issue Mar 29, 2015 · 128 comments

Comments

Projects
None yet
@rept

rept commented Mar 29, 2015

I tried everything in this thread: #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...

@leoyuholo

This comment has been minimized.

leoyuholo commented May 15, 2015

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

@thaJeztah

This comment has been minimized.

Member

thaJeztah commented May 26, 2015

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.

@kekko1212

This comment has been minimized.

kekko1212 commented Aug 11, 2015

same issue here

@tylerteh

This comment has been minimized.

tylerteh commented Aug 20, 2015

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.

@comxd

This comment has been minimized.

comxd commented Aug 28, 2015

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

@dagisus

This comment has been minimized.

dagisus commented Sep 6, 2015

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,

@vkeziah

This comment has been minimized.

vkeziah commented Sep 18, 2015

Soleved for me too with sudo command

@thaJeztah

This comment has been minimized.

Member

thaJeztah commented Sep 18, 2015

@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)

@rept

This comment has been minimized.

rept commented Sep 18, 2015

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

@rept rept closed this Sep 18, 2015

@thaJeztah

This comment has been minimized.

Member

thaJeztah commented Sep 18, 2015

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

@alexanderadam

This comment has been minimized.

alexanderadam commented Jan 4, 2016

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
@romeromfm

This comment has been minimized.

romeromfm commented Jan 19, 2016

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

@jurajseffer

This comment has been minimized.

jurajseffer commented Feb 1, 2016

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

@cloojure

This comment has been minimized.

cloojure commented Feb 24, 2016

Simple solution: sudo docker-compose up

@immarvin

This comment has been minimized.

immarvin commented Mar 10, 2016

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
@mashimom

This comment has been minimized.

mashimom commented Mar 11, 2016

That is a workaround not a solution, right?

@sergeyklay

This comment has been minimized.

sergeyklay commented Mar 11, 2016

I still often face with this

@dnephin

This comment has been minimized.

Contributor

dnephin commented Mar 11, 2016

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

@madflow

This comment has been minimized.

madflow commented Mar 12, 2016

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.

@immarvin

This comment has been minimized.

immarvin commented Mar 13, 2016

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
@dnephin

This comment has been minimized.

Contributor

dnephin commented Mar 14, 2016

If you can reproduce a connection issue with Compose and not with docker cli please open a new issue. Including all the information you have here is great, and also the error message, and a link to a paste with docker-compose --verbose up.

@chriskessel

This comment has been minimized.

chriskessel commented Mar 25, 2016

I get this if any of my container names have camel casing.

$ cat docker-compose.yml
referenceCombo:
  build: referenceCombo

$ docker-compose build
Building referenceCombo
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.

Change the name to "referencecombo" (all lowercase) and it's fine. The error message definitely doesn't help figure this one out :(

@dnephin

This comment has been minimized.

Contributor

dnephin commented Mar 25, 2016

@chriskessel I think your issue is covered by #2816, it's a bug in Docker Engine.

@vimalprakashts

This comment has been minimized.

vimalprakashts commented May 4, 2016

after restart docker services , it works for me :(

service docker restart

@Mahmoudz

This comment has been minimized.

Mahmoudz commented May 14, 2016

I had the same error, after 15 min of debugging. Turns out all it needs is a sudo :)
Check out [Create a Docker group] here https://docs.docker.com/engine/installation/linux/ubuntulinux/ to get rid of the sudo prefix.

@fabiopaiva

This comment has been minimized.

fabiopaiva commented Jun 22, 2016

Why needs to run with sudo?

@dpetzold

This comment has been minimized.

dpetzold commented Jun 30, 2016

@fabiopaiva by default docker connects to a unix socket which is a file with root user and docker group read/write privileges:

$ ls -l /var/run/docker.sock
srw-rw---- 1 root docker 0 Jun 29 23:38 /var/run/docker.sock

so you either need to be root or a member of the docker group to connect to it. If docker was listening on a tcp socket the permissions would not apply.

@pixies

This comment has been minimized.

pixies commented Jul 19, 2016

I delete file /var/run/docker.sock
how could correct?

@thaJeztah

This comment has been minimized.

Member

thaJeztah commented Jul 19, 2016

@pixies restart the docker service should recreate it

@CajuCLC

This comment has been minimized.

CajuCLC commented Feb 2, 2018

This solved my problems: https://docs.docker.com/install/linux/linux-postinstall/#manage-docker-as-a-non-root-user
Just remember to log out and log back in. Run the commands as the user you want to use docker.

@hassamali

This comment has been minimized.

hassamali commented Feb 7, 2018

sudo usermod -aG username

then Logout and login to make it work.

Worked like a charm for me.

@AydinChavez

This comment has been minimized.

AydinChavez commented Feb 13, 2018

I had to also start the docker service manually after a new installation of docker-ce (17.12.0ce-0ubuntu) and docker-compose to make the error message disappear:

sudo service docker start

@matchilling

This comment has been minimized.

matchilling commented Feb 14, 2018

Following the steps described in the documentation resolved the issue with my new Ubuntu 16.04 installation.

I had to reboot the system after applying those changes though.

@dhirajpatra

This comment has been minimized.

dhirajpatra commented Feb 16, 2018

Use command: sudo docker-compose up -d

@derekng622

This comment has been minimized.

derekng622 commented Feb 28, 2018

if u met:
$ 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.

u should check if current login user belongs to /var/run/docker.sock user group docker.
Try run Compose as sudo.

@averissimo

This comment has been minimized.

averissimo commented Mar 1, 2018

To solve this without sudo do as @leoyuholo said in the second comment and logout and back in.

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

After that logout and log back in and it works

link to comment #1214 (comment)

ps. this is for people like me that skip the first couple comments -_-

@abepetrillo

This comment has been minimized.

abepetrillo commented Mar 5, 2018

Just because it takes my a long time to re-dsicover this, and is the first thing I hit on google. There is nothing wrong with my user permissions on my laptop. The problem was the file permissions on one of the mounted folders. If you either fix the permissions so you don't need root to access them, or delete them (in my case it is cached assets for rails) it successfully goes through.

The real problem is the error message does not tell you what the specific problem is when you build via docker-compose.

@zjhken

This comment has been minimized.

zjhken commented Mar 10, 2018

I met the issue also. It is a user access issue.
I solved it by install docker-compose in root mode and run docker-compose also in root mode.

@t-buss

This comment has been minimized.

t-buss commented Mar 10, 2018

@zjhken that is not really a solution, but rather a workaround.
There is something wrong with either the file permissions in your project folder or your group permissions. See @alexcdot and my observations for the first case, and try sudo usermod -aG docker <your username> followed by re-logging-in for the latter.

@zjhken

This comment has been minimized.

zjhken commented Mar 10, 2018

@tbuss93 you're right. I have use you solution to solve it. It works. This might be the best solution.

@diptoo

This comment has been minimized.

diptoo commented Mar 15, 2018

write => sudo docker info

@HargovindArora

This comment has been minimized.

HargovindArora commented May 1, 2018

Just add sudo before the command which you are trying to run!

@danger89

This comment has been minimized.

danger89 commented May 3, 2018

So in my case the gitlab_ci_multi_runner user is part of the docker group. So that is not my issue:

groups $USER
   gitlab_ci_multi_runner : gitlab_ci_multi_runner docker

But for some reason I'm still getting SOMETIMES (notice that this is sometimes the case): Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Meaning I have the feeling my daemon is crashing or is instable? This is not handy, since I would like to have a stable and reliable continuous integration by using Docker. Any thoughts how I could debug this instability any further?

Thanks!

@piojoalejandro

This comment has been minimized.

piojoalejandro commented May 4, 2018

People, firts at all my apoligize for my english. i'm have th same problem but a realize that its happen on konsole inside kde, but when i run in a terminal crt alt f1 i dont need use sudo!. Iḿ already have $USER on docker group. I hope you ca understand me.- thanks

@alvaropaco

This comment has been minimized.

alvaropaco commented May 18, 2018

Just run;

sudo chown $USER:docker /var/run/docker.sock

@aarunakirisamy

This comment has been minimized.

aarunakirisamy commented May 22, 2018

I too faced the issue 'Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?' .Later I noticed the following.

[ec2-user@ip-172-28-6-201 docker-elk]$ which docker-compose
/usr/local/bin/docker-compose
[ec2-user@ip-172-28-6-201 docker-elk]$ which docker
/usr/bin/docker-compose

Since docker-compose binary is inside /usr/local, I was able to execute docker-compose command without 'sudo'. To execute 'docker' command, I needed sudo access.

I fixed using following commands.

cp /usr/local/bin/docker-compose /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose
sudo rm /usr/local/bin/docker-compose

Now verify 'docker-compose' command needs 'sudo' to execute.
AFter the above steps are executed, docker-compose command works for me.

@g10guang g10guang referenced this issue May 26, 2018

Closed

docker run hello-world permission denied. #340

5 of 5 tasks complete
@kuhajeyan

This comment has been minimized.

kuhajeyan commented Jun 14, 2018

after adding user to docker group
restarting the machine will do.

@roshangl

This comment has been minimized.

roshangl commented Jun 27, 2018

For me its working.
[ec2-user@ip-172-31-7-179 docker-elk]$ sudo docker-compose up -d

My docker and docker compose version are.

[ec2-user@ip-172-31-7-179 docker-elk]$ sudo docker version
Client:
Version: 17.06.2-ce
API version: 1.30
Go version: go1.8.4
Git commit: 3dfb8343b139d6342acfd9975d7f1068b5b1c3d3
Built: Fri Nov 10 00:50:37 2017
OS/Arch: linux/amd64

Server:
Version: 17.06.2-ce
API version: 1.30 (minimum version 1.12)
Go version: go1.8.4
Git commit: 402dd4a/17.06.2-ce
Built: Fri Nov 10 00:51:08 2017
OS/Arch: linux/amd64
Experimental: false
[ec2-user@ip-172-31-7-179 docker-elk]$ sudo docker-compose version
docker-compose version 1.21.2, build a133471
docker-py version: 3.4.0
CPython version: 2.7.12
OpenSSL version: OpenSSL 1.0.2k-fips 26 Jan 2017

@orapradeep

This comment has been minimized.

orapradeep commented Jul 26, 2018

after following add user procedure make sure u restart your machine.

@mikeyjk

This comment has been minimized.

mikeyjk commented Aug 3, 2018

I can reliably produce this message with a project structured like this:

├── docker-compose.yml
├── Dockerfile
└── volumes

If 'volumes' exceeds a certain size, I get the following error, when running 'docker-compose build':

  • 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.

Running the command with sudo begins to build the image, but, it's nice to not have to rely on sudo for automation.

It seems the cause of this issue in my instance is my volumes dir being passed into the build context. I guess some limitation on non-sudo users for build context size? or timeout?

So in my instance the fix is to either move the volumes dir, or add it to a .dockerignore, resolving this particular flavour of this error message.

@praveenbaliga

This comment has been minimized.

praveenbaliga commented Aug 25, 2018

cd /var/run
sudo chmod 777 docker.sock
sudo service docker start
docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.

Solved the problem :)

@bitbd83

This comment has been minimized.

bitbd83 commented Aug 27, 2018

solved with sudo

@joao-pedro-alves

This comment has been minimized.

joao-pedro-alves commented Aug 29, 2018

If everything said here don't work, reinstall docker. It worked for me.

@jerryrelmore

This comment has been minimized.

jerryrelmore commented Sep 1, 2018

No need to restart the machine in my experience which is helpful if you're in a production environment - after sudo usermod -aG docker $USER, log out and log back in. That should pass the new user group assignment to any program or app that needs it.

Failing that, @praveenbaliga 's response 3 comments up from my comment will work in a pinch if the permissions were incorrect to begin with or you're in a staging environment, but may violate security policies if you're working in a hardened production environment. You really only want root and docker group members to have access to the docker.sock and chmod 777 will give rwx access to every user.

@bpevandro

This comment has been minimized.

bpevandro commented Sep 4, 2018

/usr/lib/python2.7/dist-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.23) or chardet (3.0.4) doesn't match a supported version!
  RequestsDependencyWarning)
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.

I was having the same issue just now running $ sudo docker-compose . I became root first by doing $ sudo su, and then ran the docker-compose normally.

@nileshparwan

This comment has been minimized.

nileshparwan commented Sep 8, 2018

use this link to solve the problem as it works for me. I had the same problem but now it works fine

https://techoverflow.net/2017/03/01/solving-docker-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/

@AnostDev

This comment has been minimized.

AnostDev commented Sep 25, 2018

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

And then restart your computer

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