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: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running? #4181

Closed
matteo-bombelli opened this issue Nov 24, 2016 · 132 comments
Labels

Comments

@matteo-bombelli
Copy link

@matteo-bombelli matteo-bombelli commented Nov 24, 2016

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!

@shin-

This comment has been minimized.

Copy link
Contributor

@shin- shin- commented Nov 29, 2016

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?

@shin- shin- added the kind/question label Nov 29, 2016
@harshajayaweeraXHJ

This comment has been minimized.

Copy link

@harshajayaweeraXHJ harshajayaweeraXHJ commented Nov 29, 2016

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.

@matteo-bombelli

This comment has been minimized.

Copy link
Author

@matteo-bombelli matteo-bombelli commented Dec 3, 2016

@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

@jamethy

This comment has been minimized.

Copy link

@jamethy jamethy commented Dec 22, 2016

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.

@matteo-bombelli

This comment has been minimized.

Copy link
Author

@matteo-bombelli matteo-bombelli commented Dec 23, 2016

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

This comment has been minimized.

Copy link

@jorgeas80 jorgeas80 commented Dec 23, 2016

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

@matteo-bombelli

This comment has been minimized.

Copy link
Author

@matteo-bombelli matteo-bombelli commented Dec 23, 2016

for me the problem stays there:

Bind address needs a port: 127.0.0.1

but this number should be created by docker itself

@elikane

This comment has been minimized.

Copy link

@elikane elikane commented Dec 30, 2016

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

This comment has been minimized.

Copy link
Contributor

@shin- shin- commented Jan 4, 2017

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

@ippo012

This comment has been minimized.

Copy link

@ippo012 ippo012 commented Jan 6, 2017

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

@shin- shin- closed this Jan 24, 2017
@shashijais789

This comment has been minimized.

Copy link

@shashijais789 shashijais789 commented Feb 1, 2017

can anyone consolidate the solution for this problem in steps ?

@lalitkumarj

This comment has been minimized.

Copy link

@lalitkumarj lalitkumarj commented Feb 5, 2017

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

@furkanmustafa

This comment has been minimized.

Copy link

@furkanmustafa furkanmustafa commented Feb 8, 2017

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 :/

@shin-

This comment has been minimized.

Copy link
Contributor

@shin- shin- commented Feb 8, 2017

@furkanmustafa @shashijais789 @lalitkumarj It'd be better if you created a new issue with all the info. There are many reasons that can cause a failure to connect to the engine, from network to configuration to the engine potentially crashing / being stopped. Please also make sure to include the engine logs with the debug -D flag.

@mrjameshamilton

This comment has been minimized.

Copy link

@mrjameshamilton mrjameshamilton commented Feb 14, 2017

same problem. works with version 2, I get this error with verison 3 config.

@Kirill-Babkin

This comment has been minimized.

Copy link

@Kirill-Babkin Kirill-Babkin commented Mar 6, 2017

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

@alberto56

This comment has been minimized.

Copy link

@alberto56 alberto56 commented Mar 20, 2017

Maybe this error can be displayed if one of the images fails to build for whatever reason, not necessarily having to do with the docker daemon. For example, I have managed to debug this by trying to build each service using Docker.

My docker-compose.yml file contains:

version: '2'

services:
  # Drupal server
  drupal:
    build:
      context: .
      dockerfile: "Dockerfile-drupal"
  mysql:
    ...

Calling docker-compose build results in:

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

So I tried to use Docker to build each file individually:

docker build -f="Dockerfile-drupal" .

This gave me a more useful error:

Error checking context: 'no permission to read from some/data/directory'

Fixing that error and making sure I can build Dockerfile-drupal resulted in docker-compose build working fine.

Perhaps the code which outputs the error might be changed to something like:

Couldn't build the services.

 * Make sure you can build your Docker images using "docker build ...".
 * Make sure the Docker daemon is running.
 * If the Docker daemon is at a non-standard location, specify the URL with the DOCKER_HOST environment variable. Currently using http+docker://localunixsocket.
@kwmartin

This comment has been minimized.

Copy link

@kwmartin kwmartin commented Apr 28, 2017

Needed all of:

  1. apt-get remove and re-install using curl as Kirill-Babkin suggests (and restart socker to be safe)
  2. add user to docker group using usermod -aG, logout and login
  3. undefine DOCKER_HOST (as suggested by rkazak at https://forums.docker.com/t/docker-commands-require-sudo/12987/2) which I had earlier set using >export DOCKER_HOST=127.0.0.1:2375 as suggested by jamethy and shin
    This was on an RPi 3B. After all of this, docker is now working. Is there any chance this could be cleaned up so others don't have to go through this painful experience, as it is experiences like this docker is designed to fix? Just a suggestion.
@denis-kalinin

This comment has been minimized.

Copy link

@denis-kalinin denis-kalinin commented Jul 10, 2017

In my case LAN proxy (that is defined in Internet Options - I am on Windows) had prevented docker-compose from connecting to VM (with docker engine) on VirtualBox Host-Only Network - disabling proxy has solved an issue.

@zazaian

This comment has been minimized.

Copy link

@zazaian zazaian commented Jul 17, 2017

On Ubuntu 16.04 this worked for me:
sudo service docker start && docker-compose up -d

@ssi-anik

This comment has been minimized.

Copy link

@ssi-anik ssi-anik commented Jul 21, 2017

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

@matteo-bombelli

This comment has been minimized.

Copy link
Author

@matteo-bombelli matteo-bombelli commented Jul 24, 2017

@ssi-anik that's computer science 😄

@desertcrystal

This comment has been minimized.

Copy link

@desertcrystal desertcrystal commented Sep 16, 2017

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

@jhnoor

This comment has been minimized.

Copy link

@jhnoor jhnoor commented Sep 26, 2017

This was failing at a certain build step for me, I tried running docker build . in the same directory as the Dockerfile and found that one of the files that I was trying to COPY had permission issues.

Running sudo chmod 755 -R . fixed my issue.

@a1ec

This comment has been minimized.

Copy link

@a1ec a1ec commented Oct 6, 2017

As mentioned by @ChrisPappalardo at
#1214
check for file ownership permissions within your build directories. As the container build process is done in the context of the current user, having a inaccessible directory within the tree owned by root can lead to an error resulting in this message.

@hk0i

This comment has been minimized.

Copy link

@hk0i hk0i commented Nov 15, 2017

In my case @alberto56's solution worked perfectly it was a permissions issue with one of the volumes that was mounted to one of my services. Not sure how the ownership got changed in the first place but doing the manual docker build -f myDockerfile . helped me find my issue.

When I did an ls -l the directory was owned by 999 and docker group, the weird part is that it wasn't even for the image I was trying to build, it was a separate service.

@debauchery1st

This comment has been minimized.

Copy link

@debauchery1st debauchery1st commented Nov 18, 2017

I ran into this error because I mounted a volume like so, while debugging, and forgot to clean up.
volumes:
- ./itsLog:/var/log/itsLog

when I tried to build the Dockerfile, it must have received a "permission denied" while trying to ADD the restricted path.

The description of the error is some-what misleading, but otherwise it makes sense.

@CristianHR

This comment has been minimized.

Copy link

@CristianHR CristianHR commented May 7, 2019

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

This comment has been minimized.

Copy link

@raywjohnson raywjohnson commented May 7, 2019

This worked for me:

sudo usermod -aG docker $(whoami)

logout

login

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

@DenSul

This comment has been minimized.

Copy link

@DenSul DenSul commented May 16, 2019

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

thx!

@Vamillion

This comment has been minimized.

Copy link

@Vamillion Vamillion commented Jun 18, 2019

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

This comment has been minimized.

Copy link

@koxt koxt commented Jun 19, 2019

$ cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core) 

$ sudo service docker start
$ sudo service docker status
@sscloud88

This comment has been minimized.

Copy link

@sscloud88 sscloud88 commented Jul 4, 2019

Hello,

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

BR.Saurabh

@agamenonam

This comment has been minimized.

Copy link

@agamenonam agamenonam commented Jul 30, 2019

that command solves to me:

sudo usermod -aG docker user

@jairmondragon

This comment has been minimized.

Copy link

@jairmondragon jairmondragon commented Aug 5, 2019

commands:

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

@LandonStewart

This comment has been minimized.

Copy link

@LandonStewart LandonStewart commented Aug 5, 2019

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

This comment has been minimized.

@adamalli01

This comment has been minimized.

Copy link

@adamalli01 adamalli01 commented Aug 6, 2019

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

Please try with above command. Issue is fixed for me

@rene-oliveira

This comment has been minimized.

Copy link

@rene-oliveira rene-oliveira commented Aug 12, 2019

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

This comment has been minimized.

Copy link

@BitOfUniverse BitOfUniverse commented Aug 20, 2019

👇🏻👇🏻👇🏻👇🏻👇🏻👇🏻
👉🏽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

This comment has been minimized.

Copy link

@LandonStewart LandonStewart commented Aug 20, 2019

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

This comment has been minimized.

Copy link

@bharathvishwanathan bharathvishwanathan commented Aug 28, 2019

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

This comment has been minimized.

Copy link

@ggx-code ggx-code commented Aug 30, 2019

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

This comment has been minimized.

Copy link

@ggx-code ggx-code commented Aug 30, 2019

groups root
root : root docker
root在docker组下

@achraf-jeday

This comment has been minimized.

Copy link

@achraf-jeday achraf-jeday commented Aug 31, 2019

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

This comment has been minimized.

Copy link

@guptaRG guptaRG commented Sep 7, 2019

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

This comment has been minimized.

Copy link

@alan345 alan345 commented Sep 14, 2019

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!

@funcelotwork

This comment has been minimized.

Copy link

@funcelotwork funcelotwork commented Sep 20, 2019

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

This comment has been minimized.

Copy link

@niiokuley niiokuley commented Sep 20, 2019

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

This comment has been minimized.

Copy link

@yoola yoola commented Sep 23, 2019

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:

  • sudo docker ps (shows information about your running dockers)
  • docker stop "Here the ID of your container" (e.g. mine was e6339eae0675)
  • sudo docker rm "Here the ID of your container"
  • sudo docker-compose up -d
@patsotoe

This comment has been minimized.

Copy link

@patsotoe patsotoe commented Sep 24, 2019

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

@mahdi-malv

This comment has been minimized.

Copy link

@mahdi-malv mahdi-malv commented Oct 3, 2019

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

@edescourtis

This comment has been minimized.

Copy link

@edescourtis edescourtis commented Oct 3, 2019

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

This works.

@sijpkes

This comment has been minimized.

Copy link

@sijpkes sijpkes commented Oct 15, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.