Skip to content
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

ERROR #6677

Closed
aminancelot opened this issue Apr 29, 2019 · 42 comments
Closed

ERROR #6677

aminancelot opened this issue Apr 29, 2019 · 42 comments

Comments

@aminancelot
Copy link

aminancelot commented Apr 29, 2019

No description provided.

@bbalaran
Copy link

Agreed. I am seeing errors reported in the daemon that are not being reported back to the CLI. "Couldn't connect" is clearly erroneous in many cases.

@ajbazz
Copy link

ajbazz commented May 2, 2019

I had that error and it stopped when I ran every command as sudo.
Try it out..

@aminancelot
Copy link
Author

@ajbazz No. Clearly no. just add your user in the docker group, fixed. You shouldn't run that kind of command using sudo.

What I mean here is that many types of errors, syntax errors, connectivity errors, not having the right to connect, etc... are all leading to the same message.

Your issue for example should say "OK, the daemon seem to run but I don't have rights to connect, are you in the docker group?" or something of the kind. See the links I pointed to and you'll start to see the diversity of errors reporting the same message. This is clearly a usability issue.

@jcsirot
Copy link

jcsirot commented May 6, 2019

Hello @aminancelot Thank you for reporting this issue. We are going to evaluate this enhancement but note that any Pull Request improving the error reporting would also be greatly appreciated.

@danschmidt5189
Copy link

danschmidt5189 commented May 13, 2019

@jcsirot Just FYI, if your image: declaration contains an invalid tag (e.g. one with both lower and upper-case characters) docker-compose --build returns this error. Ran into this a few times over the past few weeks debugging Jenkins builds and the default error was confusing/misleading.

E.g. if you build this Compose spec with docker-compose:

services:
  app:
    build: .
    image: some-repo:myTagWithUppercaseChars

version: 3.5

You'll get this wrong and confusing error message:

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

By contrast, a traditional docker build gives a meaningful error message:

$ docker build -t some-repo:myTagWithUppercaseChars .
invalid argument "some-repo:myTagWithUppercaseChars" for "-t, --tag" flag: invalid reference format: repository name must be lowercase
See 'docker build --help'.

There's a bit more discussion of this general problem on Medium. The tl;dr is that docker-compose build gives meaningless errors in a variety of situations. Once you know that's the case it's not the end of the world, but obviously it would be better to surface the correct error.

@ajbazz
Copy link

ajbazz commented May 14, 2019 via email

@janhn
Copy link

janhn commented Jun 17, 2019

What I'm seeing in one of my use-cases is that Docker daemon drops connection in the middle of processing of a build command, without providing any error. docker-compose produces the same message, which is very misleading.

I'd attempt to fix by extending handle_connection_errors, but not sure that's the right way...

@rdissertori
Copy link

rdissertori commented Jul 7, 2019

I got the very same error when building an image. I have changed the location of my docker to a different location (via systemd) by using the "-g" parameter

When I delete the whole docker folder and restart docker it will work temporarily.
After a system boot or service restart I'm having this issue again.

docker-compose version 1.24.1, build unknown
docker version 18.09.6-ce, build 481bc77156
Linux 4.19.56-1-MANJARO #1 SMP PREEMPT x86_64 GNU/Linux

@rafa-munoz
Copy link

This worked for me on Ubuntu 18.04:

  1. sudo usermod -aG docker $USER
  2. sudo chmod 755 -R .
  3. Restart your computer.

@jmleroy
Copy link

jmleroy commented Oct 29, 2019

Same as Menda. The problem appeared after an aborted build. One of my images used a directory that was suddenly belonging to 999 instead of me. chmod fixed it.

@OlivierJM
Copy link

running the command with sudo fixed the issue

@ndeloof
Copy link
Contributor

ndeloof commented Nov 19, 2019

People reporting issue here don't give more details on the condition this error is reported. Running with sudo is definitely not a good solution, if you read this because you encounter a comparable issue, please double-check current user is in the docker group and as such can execute docker CLI and access the engine without permission error.

Closing as not a well described issue we could investigate. If you get such an error please open a new issue and provide a complete description of your environment

@danschmidt5189 I tried to reproduce the more detailed issue you reported and can't reproduce with 1.24.1. I get expected error when running docker-compose build with an invalid uppercase reposiutory name :

➜  docker-compose build
Building app
ERROR: invalid reference format: repository name must be lowercase

@ndeloof ndeloof closed this as completed Nov 19, 2019
@aminancelot
Copy link
Author

@ndeloof Oh come on! There is no more detail because any error reports the same message and developers couldn't be bothered to do proper error reporting. Please reopen this issue and fix the problem instead of denying it's existence. Seems to me it's getting closed out of laziness. Please reopen it and let someone willing do it.

@ndeloof
Copy link
Contributor

ndeloof commented Nov 20, 2019

@aminancelot I can understand your frustration, but you didn't even provided compose/docker version you're using, command being ran, or anything that could help us understand what's going wrong.

I'd be happy to assist you if you still encounter this issue, but then please use the issue template so we gather enough information to offer adequate assistance and diagnostic

@aminancelot
Copy link
Author

Alright, fair enough, I was expecting that the "all routes lead to rome" behaviour could be corrected instead of doing a case by case. At least I know now, if I meet this issue virtually anything can be the error, a syntax error in the compose file can be it.

To anyone coming here finding this issue, if you consider compose, avoid the frustration and wasted time. Look for something else.

@ndeloof
Copy link
Contributor

ndeloof commented Nov 20, 2019

No need to be rude.
I took time trying to reproduce the registry uppercase scenario reported by @danschmidt5189 and can't reproduce on 1.24.1, so probably this specific path was fixed already. This high level error is probably hidding many potential lower level errors, there's no silver bullet to just fix them all. So, yes, we need some more detailed report on concrete issues so we can track them down the rabbit hole into root cause, and offer a fix on a case-by-case basis.

@aminancelot
Copy link
Author

I don't think I'm being rude, I'm simply being realistic. It's unfortunate writing doesn't convey tone. Sorry if it seemed so.

I have met this error message for multiple different syntax errors. The link mentioned at the opening of the issue clearly shows different reproducible scenarios in which this is happening.
I'm not rude, I'm just frustrated a good project undermined by something so trivial. I wish I had time to help on it but let's face it, if about anything reports the same error, it's not usable.

@ndeloof
Copy link
Contributor

ndeloof commented Nov 20, 2019

The first scenarios reported in the blog post would just be confirmed by trying to run docker info and confirming user just has no permission to access the docker daemon. Then "Couldn't connect to Docker daemon" sounds a reasonable error message, maybe could be rephrased.

The last "different ownership" scenario sounds pretty exotic to me. Could investigate further. Anyway writting a blog post is clearly not the best way to report issues to a project :P

@danschmidt5189
Copy link

@ndeloof I'm still seeing this in our CI system when testing a build for (essentially) repo/project/testUpperCaseBranchName-docker:latest. If I forcibly lower-case the branch name (the last part of the registry path), everything's fine, but otherwise I get the same error as before:

> docker --version
Docker version 19.03.5, build 633a0ea

> docker-compose --version
docker-compose version 1.25.0, build b42d419

> docker-compose build --pull
Building ansible-test
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 DOCK ER_HOST environment variable.
script returned exit code 1

It's not a huge deal for us to workaround, but it's weird that I'm still seeing this error and you aren't. (I wonder if the bug was re-introduced in 1.25.0?)

@ndeloof
Copy link
Contributor

ndeloof commented Nov 21, 2019

Tried on another computer (OSX):

➜  ~/Downloads/docker-compose-Darwin-x86_64 version
docker-compose version 1.25.0, build 0a186604
docker-py version: 4.1.0
CPython version: 3.7.4
OpenSSL version: OpenSSL 1.1.1c  28 May 2019
➜  ~/Downloads/docker-compose-Darwin-x86_64 build
Building app
ERROR: invalid reference format: repository name must be lowercase

I'll investigate further and add a test case to enforce we handle this scenario

@ndeloof
Copy link
Contributor

ndeloof commented Nov 21, 2019

The error message I get is actually sent from docker engine (19.03.5)
https://github.com/docker/distribution/blob/master/reference/normalize.go#L44
This is not a recent change, so it's surprising you don't get the same - maybe some other error is hiding this one, which would have been useful to diagnose this scenario.

@danschmidt5189 which version of docker engine are you running (just run docker version) ?

jonpugh added a commit to opendevshop/devshop that referenced this issue Jan 8, 2020
@pawaroti
Copy link

https://docs.docker.com/install/linux/linux-postinstall/

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

this helped in my case.

@herrjemand
Copy link

Thanks @pawaroti! That helped!

@leonjia0112
Copy link

This worked for me on Ubuntu 18.04:

  1. sudo usermod -aG docker $USER
  2. sudo chmod 755 -R .
  3. Restart your computer.

It works for my ubuntu 18

@quyen91
Copy link

quyen91 commented Mar 9, 2020

https://docs.docker.com/install/linux/linux-postinstall/

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

Only solution work for my ubuntu 18.4

@m-petuhov
Copy link

Only this works for me:

You don't have a docker daemon, check it out:
dockerd
For install him:
sudo apt install docker.io

@wireshocks
Copy link

Guys a magic for this problem!

  1. open the terminal and type sudo dockerd and leave it open
  2. open new terminal and type sudo docker-compose up -d
  3. booom

@Kledenai
Copy link

Really the problem is with permission like @wireshocks said run sudo docker-compose up -d and booom

@ralyodio
Copy link

I never had to use sudo docker-compose before. why do I have to start now? Ubuntu 20.04

@coolsam726
Copy link

I struggled with the problem for a while, turns out the issue was that my services.app.image contained invalid characters. I fixed the image name and boom! No more such error.
Quick note: If you are specifying your values in the .env file, ensure they don't have quotes. For example instead of DOCKER_APP_IMAGE_NAME="myimage" use DOCKER_APP_IMAGE_NAME=myimage

@AshishKapoor
Copy link

I had that error and it stopped when I ran every command as sudo.
Try it out..

Worked on Fedora OS 31. Thanks!

@laszukdawid
Copy link

This thread nicely shows that people don't read and search from the bottom for a potential solution to copy/paste.

The original concern was that that message appearing as a catch all exception but then it turned to be a defence for the most common root cause. Grotesque.

@Gtstride
Copy link

Gtstride commented Jun 18, 2020

Thanks, @wireshocks, worked for me.

@tebs85
Copy link

tebs85 commented Jun 29, 2020

I ran into the same problem and this article assisted me to solve the issue.
It's easy to follow and short. Hope it helps others.
https://medium.com/@ibrahimgunduz34/if-you-faced-an-issue-like-couldnt-connect-to-docker-daemon-at-http-docker-localunixsocket-is-27b35f17d09d

@ArthurYdalgo
Copy link

Guys a magic for this problem!

  1. open the terminal and type sudo dockerd and leave it open
  2. open new terminal and type sudo docker-compose up -d
  3. booom

bro... you just saved my day

@OpetherMB
Copy link

I had that error and it stopped when I ran every command as sudo.
Try it out..

thank you alot

@etotheipi
Copy link

etotheipi commented Aug 17, 2020

In my case, the issue was as reported @jmleroy . Some directories within my build tree had become owned by root, which I guess was diverting docker daemon somehow while it was indexing the directory structure. I simply chown'd everything back to my user and it works now (no reboot needed):

# MAKE SURE YOU ARE IN YOUR PROJECT DIRECTORY
$ sudo chown -R <username>:<username> *

@gatemezing
Copy link

I ran into the same problem and this article assisted me to solve the issue.
It's easy to follow and short. Hope it helps others.
https://medium.com/@ibrahimgunduz34/if-you-faced-an-issue-like-couldnt-connect-to-docker-daemon-at-http-docker-localunixsocket-is-27b35f17d09d

Yes, you saved my day. It works on CentOS 17

@iamleson98
Copy link

iamleson98 commented Oct 14, 2020

I had that error and it stopped when I ran every command as sudo.
Try it out..

Wow, you are absolutely RIGHT. sudo solves all the problems.
Thank you, mr @ajbazz

@aminancelot
Copy link
Author

aminancelot commented Oct 14, 2020

I'm staggered by all those comments.
This ticket is NOT AND WAS NEVER ABOUT using sudo or not, if you had read the documentation, you don't need (and shouldn't) use sudo.

This ticket is about about every issue compose meets ends up reported with that same message.
This ticket was then closed by @ndeloof who concluded there was not enough info when enough info was provided.

In other words, this ticket is a mess and a shame. I regret having wasted time reporting it.
Please @ndeloof at least prevent new comments if you won't investigate the issue.

@vzverv
Copy link

vzverv commented Oct 15, 2020

https://docs.docker.com/install/linux/linux-postinstall/

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

this helped in my case.

worked like a charm for Ubuntu 20.04
thanks!

@aminancelot aminancelot changed the title ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running? ERROR Oct 15, 2020
@sheedy
Copy link

sheedy commented Nov 22, 2020

I was getting Couldn't connect to Docker daemon at http+docker://localhost - is it running? which turned out to be a syntax error in my compose file due to a dynamic variable not being passed.

Running docker-compose config -f my-docker-compose-file.yml showed me that it was missing.

I was using the following dynamic value which I forgot to set in my shell before running docker-compose and wasn't warned about:

...
image: image-name:${TAG}
...

To avoid getting docker-compose's generic error, you can do this instead so that you are warned when a dynamic value is not found:

...
image: image-name:${TAG?TAG value is required}
...

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

Successfully merging a pull request may close this issue.