docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
33.89k stars 5.21k forks source link

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

Closed matteo-bombelli closed 7 years ago

matteo-bombelli commented 7 years ago

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 think that I've tried all the possible configurations am I right?


Specs:


Thank You!

errorstudent commented 5 years ago

this worked for me sudo chown $USER:docker /var/run/docker.sock

Olvikolvi commented 5 years ago

usermod -a -G docker USER Then logout and login again USER.

Dzhuneyt commented 5 years ago

I encountered the same error whenever I had a variable inside docker-compose.yml that is NOT present within .env.

Weird error for such scenario but - whatever. :)

Shaline commented 5 years ago

just type sudo before your docker-compose command!

Take your like, sir! omg..., but works fine for me, great job!

tarunbhavnani commented 5 years ago

i just had to do: sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

and it worked!

CristianHR commented 5 years ago

Yo instalรฉ docker-compose y la vez resolvรญe el problema con los siguientes pasos: paso 1: sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s-uname -m` -o /usr/local/bin/docker-compose

paso 2: sudo chmod +x /usr/local/bin/docker-compose

paso 3: docker-compose --version

paso 4: export DOCKER_HOST=127.0.0.1:2375

paso 5: usermod -a -G docker $USER

paso 6: Reiniciar tu pc o ejecutar el comando shutdown

raywjohnson commented 5 years ago

This worked for me:

sudo usermod -aG docker $(whoami)

logout

login

check to be sure you are in the "docker" group.

DenSul commented 5 years ago

- sudo chown $USER:docker /var/run/docker.sockThis worked for me in a ubuntu 18 setup.

thx!

Vamillion commented 5 years ago

Hello, got same error message:

ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running? If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

But this message was misleading, because my docker deamon does not had any problems in connections. The reason was a stupid mistake I made in the Yaml (which I didn't know before). I accidentally had a capital letter in the image name. That led to the fact that the service could not be formed, since only lower case letters are permitted as names. I noticed the error when I tried to build the Dockerfile separately with the names. It would be handy if docker-compose could forward the errors that occur within build problems. Since, as @shin- also said, this bug can still occur for many reasons at this time. Even though it's been some time since @shin- wrote this, the problem still seems to exist. Maybe it might be helpful.

Just posting my issue here, cause everyone is strictly thinking on real connection problems with docker and i wanted to show, that it does not need to be always the case.

koxt commented 5 years ago
$ cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core) 

$ sudo service docker start
$ sudo service docker status
sscloud88 commented 5 years ago

Hello,

I faced the same issue. But it got resolved after I restarted my VM.

BR.Saurabh

agamenonam commented 5 years ago

that command solves to me:

sudo usermod -aG docker user

josejairmondragonrios commented 5 years ago

commands:

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose sudo docker-compose up -d

landonstewart commented 5 years ago

If you just installed docker and just granted a user the docker group try logging out of that user and logging back in again.

Andran77 commented 5 years ago

https://www.digitalocean.com/community/tutorials/docker-ubuntu-18-04-1-ru

adamalli01 commented 5 years ago

sudo service docker start && docker-compose up -d

Please try with above command. Issue is fixed for me

rene-oliveira commented 5 years ago

None of the listed above solutions have fixed it for me. Any other ideas?

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

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

resolvi o problema com esse comando:

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

BitOfUniverse commented 5 years ago

๐Ÿ‘‡๐Ÿป๐Ÿ‘‡๐Ÿป๐Ÿ‘‡๐Ÿป๐Ÿ‘‡๐Ÿป๐Ÿ‘‡๐Ÿป๐Ÿ‘‡๐Ÿป ๐Ÿ‘‰๐ŸฝSOLUTION ๐Ÿ‘ˆ ๐Ÿ‘†๐Ÿฟ๐Ÿ‘†๐Ÿฟ๐Ÿ‘†๐Ÿฟ๐Ÿ‘†๐Ÿฟ๐Ÿ‘†๐Ÿฟ๐Ÿ‘†๐Ÿฟ

if you haven't tried anything yet from this tread run these two commands and it will solve this particular problem: sudo usermod -a -G docker $USER # adds your current user to docker group newgrp docker # activates new permissions for docker group

landonstewart commented 5 years ago

sudo usermod -a -G docker $USER # adds your current user to docker group newgrp docker # activates new permissions for docker group

Should be newgrp -l docker. When using this people should be aware that newgrp starts a new shell so their environment will be reset as if they logged in freshly again if they use -l.

bharathvishwanathan commented 5 years ago

First we need to remount tmp with exec permission by executing

  1. sudo mount /tmp -o remount,exec then make docker up by
  2. "service docker start" in root user or "sudo service docker start" then
  3. "docker-compose up" or "docker-compose start" worked for me
ggx-code commented 5 years ago

sudo docker-compose up -d ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable. ๅŠ ไธŠsudoไนŸๆ˜ฏๆŠฅๅŒๆ ท็š„้”™่ฏฏ

ggx-code commented 5 years ago

groups root root : root docker rootๅœจdocker็ป„ไธ‹

achraf-jeday commented 5 years ago

Resolved the issue with this:

  1. sudo usermod -aG docker $USER
  2. Log out and log back in so that your group membership is re-evaluated.
  3. Verify that you can run docker commands without sudo: docker info
guptaRG commented 5 years ago

The default DOCKER_HOST is unix:///var/run/docker.sock . If this file doesn't exist or your current user doesn't have access to that file then its trying to connect to http+docker://localhost Try: sudo chown /var/run/docker.sock Then again try to run docker-compose up Worked for me.

alan345 commented 5 years ago

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? Thanks! it works!

But please Docker, add a correct warning!

default-work commented 5 years ago

i got this message when copying volumes from poruction machine, ended up to owerdrite metadata.db inside /var/lib/docker/volumes, then it crashes. A fix is so smiple

docker system prune --volumes -f && rm /var/lib/docker/volumes/metadata.db && docker-compose up -d
DrewWorks commented 5 years ago

This often happens when you run docker commands as sudo whiles you run docker-compose commands without it. What you need to do is to add docker user to the sudo group. (ie. usermod -aG docker $USER) Then you can run both comands (docker and docker-compose) without sudo.

yoola commented 5 years ago

I had exactly the same error. I removed the container (id) and started the docker again. That fixed the problem for me. It doesn't delete any data which was already uploaded.

Go into your cvat directory and run the following in your terminal:

patsotoe commented 5 years ago

i have the same problem, sudo docker-compose up work for me.

mahdi-malv commented 5 years ago

The solution for me was to stop my openvpn that I was using.

edescourtis commented 5 years ago

I am not sure what happened, I restarted my PC and it started working!!

This works.

sijpkes commented 5 years ago

the following steps solved the problem for me.

remove docker: $ sudo apt-get remove docker docker-engine reinstall with curl -sSL https://get.docker.com/ | sh

add user to a group: sudo usermod -aG docker user

Just a note that you need to exit the shell and login again for the usermod command to stick.

Wolfium commented 4 years ago

I just suffered again same issue as before, and found sime light at the end... It it is related to that docker-compose shows this weird message hiding the real issue. I just tried to build one of the images with docker build . and then it showed up that some files trying to be included in the cache had no permissions to read and build failed. Once removed issued files it started working again with no issues. In my case mounting current dir was the issue as test generate directories with root users on the hosts So next time build failed because it can't read and start failing build with no clear messsage from docker-compose build. Need to check user run test to avoid the issue later but hope this helps others to find the real issue.

Regards

bbotte commented 4 years ago

add regular users to the docker group

# usermod -a -G docker user
# exit
$ exec $SHELL
$ docker-compose ps
nathansalter commented 4 years ago

I fixed this by unsetting the CONTAINER_REGISTRY_BASE variable

dianne21 commented 4 years ago

$ sudo usermod -aG docker $USER

hjwp commented 4 years ago

I found it was a missing environment variable that was breaking the image: settings in docker-compose.yml

ยฏ_(ใƒ„)_/ยฏ

aayushgupta97 commented 4 years ago

the following steps solved the problem for me.

remove docker: $ sudo apt-get remove docker docker-engine reinstall with curl -sSL https://get.docker.com/ | sh

add user to a group: sudo usermod -aG docker user

Thank You. Uninstalling, then reinstalling and changing user permissions and logging out and logging back in solved it for me.

l1x commented 4 years ago

None of the listed above solutions have fixed it for me. Any other ideas? ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running? If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

resolvi o problema com esse comando:

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

This fixed it for me.

pavankjadda commented 4 years ago

I did everything except symbolically linking to docker-compose. Following commands fixed my issue

  1. Add user to docker group (if not already added) sudo usermod -aG docker $USER
  2. create a symbolic link to /usr/bin using the following command $ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
  3. Restart docker service $ sudo service docker restart
p-mcgowan commented 4 years ago

In my case, none of the above worked

As it turned out, in my compose file I had a camelCase image name (eg imageName), and that was causing Couldn't connect to Docker daemon at http+docker://localunixsocket. Changing that to dash-case solved the problem (very strange). Docker service was running fine, docker ps and info were also reporting no issues, just launching that compose file was the issue.

Ubuntu 18.04
docker 19.03.6
docker-compose 1.17.1 (compose file version 3)
MuhammadUmairMoosani commented 4 years ago

sudo docker-compose up -d

Grawl commented 4 years ago

just faced this issue again and realized I must restart Ubuntu after adding mu user to Docker group

halaxa commented 4 years ago

sudo usermod -aG docker user

This by @Kirill-Babkin solved it for me. I had newly created user not in docker group. Thanks.

mageddo commented 4 years ago

In my case my docker-compose.yml was missing env var definition on image section

prod-image-generation:
    image: my-image:${BUILD_NUMBER}

I Lost about 30 minutes with it. Please suggest a meaningful error for this

Solution was set a value for the var

l3lackcurtains commented 4 years ago

Just the empty export worked for me.

export DOCKER_HOST=
mikemix commented 4 years ago

Fresh Docker installation here in Ubuntu 18. Assuming your user is already in the docker group, just install the docker service so it autostarts sudo systemctl enable docker then restart and voila sudo init 6

holdmypotion commented 4 years ago

Had the same problem. Solved on my system by writing "docker-compose build"

renstanforth commented 4 years ago

I just had the same issue. I found that for some reason my user was not added to the docker security group, in turn not allowing me permission on docker's unix socket and giving me ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running.

Adding the docker group to my current user, then logging out and back in again fixed everything for me: sudo usermod -aG docker $USER

Followed this, then restarted the machine, and ran docker-compose up --build ๐Ÿ‘

agnsuporte commented 4 years ago

show