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 · 222 comments

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-
Copy link

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

@harshajayaweeraXHJ
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
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
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
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
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
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
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-
Copy link

@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
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
Copy link

@shashijais789 shashijais789 commented Feb 1, 2017

can anyone consolidate the solution for this problem in steps ?

@lalitkumarj
Copy link

@lalitkumarj lalitkumarj commented Feb 5, 2017

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

@furkanmustafa
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-
Copy link

@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
Copy link

@mrjameshamilton mrjameshamilton commented Feb 14, 2017

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

@Kirill-Babkin
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
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
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
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
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
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
Copy link
Author

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

@ssi-anik that's computer science 😄

@desertcrystal
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
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
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
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.

@trevorjamesmartin
Copy link

@trevorjamesmartin trevorjamesmartin 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.

@engpakravan
Copy link

@engpakravan engpakravan commented Aug 19, 2020

sudo chmod 666 /var/run/docker.sock

As said here before, this may open a security hole in your system. Did you try the usermod solution before that? It may rise security concerns, too, because it gives that user complete access over docker, but compared to giving every user access to a root-owned file it seems to be the lesser evil.

You're telling right , but this is very important for devops , i just a developer and i fix that using this command ,
special thank to @shqear93

@dansgithubuser
Copy link

@dansgithubuser dansgithubuser commented Aug 19, 2020

This is painful and I'm incredulous that the issue has been closed three years ago with no meaningful response from Docker. This github issue shouldn't be in your feature set. What's the plan for straightening this out? Don't punt this to users who don't understand how groups and users and sessions work, or other pieces of software that work the way they do. You chose this complicated way of doing things.

I had to restart my computer instead of logout/login for sudo usermod -aG docker my_user to take effect. Some evidence of this happening to others here: https://unix.stackexchange.com/questions/277240/usermod-a-g-group-user-not-work.

@ghost
Copy link

@ghost ghost commented Aug 22, 2020

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

also, don't forget to run newgrp docker to get access to that group in your current shell. ref https://stackoverflow.com/a/48569858/2040522

Worked perfectly for me. Thanks!

@abrarShariar
Copy link

@abrarShariar abrarShariar commented Aug 24, 2020

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

this worked for me!

@hashimyousaf1
Copy link

@hashimyousaf1 hashimyousaf1 commented Aug 27, 2020

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

also, don't forget to run newgrp docker to get access to that group in your current shell. ref https://stackoverflow.com/a/48569858/2040522

This solved my problem, thanks!!!

@JuicyJuuce
Copy link

@JuicyJuuce JuicyJuuce commented Aug 31, 2020

I have no idea why, but what fixed it for me was removing the following line from my docker-compose .env file:

DOCKER_HOST=tcp://localhost:2375

@MohammadHeydari
Copy link

@MohammadHeydari MohammadHeydari commented Sep 14, 2020

Solved by :

sudo chmod 666 /var/run/docker.sock

Thanks. Solved in Ubuntu 20.0.4 LTS

@dPhantum
Copy link

@dPhantum dPhantum commented Sep 30, 2020

I just got tried of playing with permissions and just did:

sudo docker-compose build

And it was off to the races.
At the heart of it a permissions issue, if have have the docker service running, group assigned, socket permissions all set, and still didn't see it working. Just do it with sudo. Worked for me, have better things to do.

@ralyodio
Copy link

@ralyodio ralyodio commented Nov 8, 2020

any solution for ubuntu 20.04?

@Taranchul
Copy link

@Taranchul Taranchul commented Nov 8, 2020

any solution for ubuntu 20.04?

Did you try the solution posted before? (#4181 (comment))

In short (with added later suggestions):

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

If "newgrp docker" doesn't suffice, a reboot may be neccessary (there are conflicting comments about that).

@Mohamedcond Mohamedcond mentioned this issue Nov 22, 2020
@sheedy
Copy link

@sheedy 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}
...

@DavidPesticcio
Copy link

@DavidPesticcio DavidPesticcio commented Dec 1, 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}
...

This issue still exists in docker-compose version 1.27.4, build 40524192:

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

Had nothing to do with any of the solutions listed above - it was a right ole red-herring chase for me! 😄

While docker-compose config parses the file successfully, docker-compose build will fail.

For me it was a double slash // in my docker-compose.yml file, in the image: entry that caused the issue...

If ${DOCKER_USER} or ${DOCKER_IMAGE_NAME} cause a double slash / then docker-compose build will fail:

...
    image: ${DOCKER_USER}/${DOCKER_IMAGE_NAME}:${DOCKER_TAG}
...

Removing the superfluous slash / fixed the problem for me. (I actually trail the / in ${DOCKER_USER} so that I can omit the user portion of the image: URI if necessary without breaking the build.)

Many thanks to @sheedy for the hint! 😉

Can we fix the docker-compose config parser please, and wave goodbye to this issue? 😄 👍

Additional info:

docker info
Client:
 Debug Mode: false

Server:
 Containers: 8
  Running: 8
  Paused: 0
  Stopped: 0
 Images: 55
 Server Version: 19.03.13
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ea765aba0d05254012b0b9e595e995c09186427f
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 5.8.0-0.bpo.2-amd64
 Operating System: Debian GNU/Linux 10 (buster)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 15.6GiB
 Name: omv.localdomain
 ID: WY5F:C62I:HKE4:LXKX:B7US:SVZF:GN55:L6SF:HIO2:CDZW:64UZ:J6MY
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
docker version
Client: Docker Engine - Community
 Version:           19.03.13
 API version:       1.40
 Go version:        go1.13.15
 Git commit:        4484c46d9d
 Built:             Wed Sep 16 17:02:55 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.13
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       4484c46d9d
  Built:            Wed Sep 16 17:01:25 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.3.9
  GitCommit:        ea765aba0d05254012b0b9e595e995c09186427f
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
docker-compose version
docker-compose version 1.27.4, build 40524192
docker-py version: 4.3.1
CPython version: 3.7.7
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019

@stefek99
Copy link

@stefek99 stefek99 commented Dec 17, 2020

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.

just use sudo

Sometimes I wish error messages were more helpful.

But yeah, quick google search for error, scrolling to find an answer that has the most emoji reactions and it works 🎉

@Taranchul
Copy link

@Taranchul Taranchul commented Dec 17, 2020

just use sudo

Sudo shouldn't be necessary, did you try the solution posted here before?

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

If "newgrp docker" doesn't suffice, a reboot may be neccessary (there are conflicting comments about that).

After that, docker commands should work without sudo.

@j3pic
Copy link

@j3pic j3pic commented Dec 17, 2020

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

It was the last bit that was the problem in my case. Docker-compose should not be silently swallowing error messages. It would have saved me an hour or two if docker-compose simply let the exception crash the program with the original "Permission denied: '/var/run/docker.sock'" error message instead of covering it up and showing a "friendly" error message with a thousand possible causes instead.

@rehanguha
Copy link

@rehanguha rehanguha commented Dec 27, 2020

I was facing this similar issue on Ubuntu. The below command solved my problem.

sudo chmod 666 /var/run/docker.sock

@dadenewyyt
Copy link

@dadenewyyt dadenewyyt commented Jan 13, 2021

docker-compose build

Use sudo docker-compose build

@Ivor
Copy link

@Ivor Ivor commented Feb 11, 2021

Ubuntu 20.0.4 LTS

Initially with this command

docker-compose up

I got the same error.

Then I saw the comment about changing the permissions on docker.sock
Then this worked:

sudo docker-compose up

Then I saw the comment about Ubuntu not adding the user to the docker group, so I
returned the docker.sock file to its original permissions:

sudo chmod 660 /var/run/docker.sock

and then I did

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

and then this worked:

docker-compose up

@dmytro-kerest
Copy link

@dmytro-kerest dmytro-kerest commented Feb 17, 2021

it might help someone someday.
install docker-compose tool from docker website instructions and NOT from the repo of your distribution - in most cases it is outdated.
I have trie everything from the list here and the only thing that did work is installing latest docker-compose

@aguschapuis
Copy link

@aguschapuis aguschapuis commented Feb 25, 2021

Try with sudo chmod 666 /var/run/docker.sock

@Taranchul
Copy link

@Taranchul Taranchul commented Feb 25, 2021

Try with sudo chmod 666 /var/run/docker.sock

This makes the file writable by every user which is a potential security risk in a system directory. That should only be considered as a last resort after trying the safer solution posted here before:

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

@MUKESHBADIGINENI
Copy link

@MUKESHBADIGINENI MUKESHBADIGINENI commented Mar 22, 2021

I tried the following process, it's working perfectly in my case.....!!

  1. Check "hostname" in your script.
  2. Run the command with sudo.
    sudo docker-compose up -d
  3. Once the image files downloaded and extracted it will start the network.
    image

@klongbeard
Copy link

@klongbeard klongbeard commented Apr 21, 2021

hey i'm late to the party I know but for anyone who gets this error on a live server just log out and back in again. When you add your user to the docker group you need to reload your terminal to get the updated permissions.

@facundopadilla
Copy link

@facundopadilla facundopadilla commented May 7, 2021

newgrp docker

This work's me fine !

@ANANTASHESHALOKAGREENTARAEGPTRANSHOLON

sudo chown -Rv someuser.someuser ~someuser/ helped me to fix. someuser is the user i develop under and run docker-compose under it, too.

@vigi04
Copy link

@vigi04 vigi04 commented Aug 25, 2021

Sometimes, the error comes when the Image name contains uppercase characters..

service-name:
image: Abcd/Xyz
build: ..

corrected compose file

service-name:
image: abcd/xyz
build: ..

@maxshuang
Copy link

@maxshuang maxshuang commented Sep 6, 2021

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.

work for me

@hannwei
Copy link

@hannwei hannwei commented Sep 11, 2021

"sudo docker-compose up" will most likely solve the problem.

But for people who do not want to sudo on docker-compose for security reasons, this may help :

sudo chgrp -R docker /var/run/docker

No idea which file really needs it. But changing the group of all those docker files probably does not cause harm. That is a docker group anyway.

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

Successfully merging a pull request may close this issue.

None yet