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

dial unix /var/run/docker.sock: permission denied #5314

Closed
cdekok opened this issue Apr 19, 2014 · 36 comments
Closed

dial unix /var/run/docker.sock: permission denied #5314

cdekok opened this issue Apr 19, 2014 · 36 comments

Comments

@cdekok
Copy link

cdekok commented Apr 19, 2014

I installed docker.io on ubuntu 14.04 only i always get this message:

dial unix /var/run/docker.sock: permission denied

I read this was an old problem, i see it does belong to the group docker, and I have tried adding myself to the docker group to but i still get this message, does anybody know how to solve it?

The version that comes with ubuntu is: Docker version 0.9.1, build 3600720

@lkoenigsberger
Copy link

I`ve the same problem. Thought first it is a config error or an error because of running the VM in Microsoft Azure ;-) But I'm not alone!!
What are we missing??

@tianon
Copy link
Member

tianon commented Apr 19, 2014

Did you log out and back in after adding yourself to the docker group?

@lkoenigsberger
Copy link

Sorry yes that was the problem!! After rebooting the server it worked!! Thanks

@tianon
Copy link
Member

tianon commented Apr 19, 2014

@mech7 was that the issue for you as well?

@cdekok
Copy link
Author

cdekok commented Apr 19, 2014

Yes seems to be working now thanks :)

@cdekok cdekok closed this as completed Apr 19, 2014
@tuminoid
Copy link

This issue still persists on Trusty and Docker 0.9.1, build 3600720.
I have rebooted. Running kernel 3.14.2-lowlatency from Ubuntu mainline PPA.

$ groups
tumi adm cdrom sudo dip plugdev lpadmin sambashare docker

$ docker -d
[/var/lib/docker|a0e25760] +job serveapi(unix:///var/run/docker.sock)
[/var/lib/docker|a0e25760] +job initserver()
[/var/lib/docker|a0e25760.initserver()] Creating server
2014/05/15 08:10:33 Listening for HTTP on unix (/var/run/docker.sock)
listen unix /var/run/docker.sock: bind: permission denied
[/var/lib/docker|a0e25760] -job serveapi(unix:///var/run/docker.sock) = ERR (1)
2014/05/15 08:10:33 listen unix /var/run/docker.sock: bind: permission denied

$ sudo start docker.io
docker.io start/running, process 16801

$ dmesg | tail -n5
[ 1212.552302] init: docker.io main process ended, respawning
[ 1212.583319] init: docker.io main process (17116) terminated with status 1
[ 1212.583329] init: docker.io main process ended, respawning
[ 1212.616100] init: docker.io main process (17151) terminated with status 1
[ 1212.616111] init: docker.io respawning too fast, stopped

$ sudo docker -d
[/var/lib/docker|e0b714e0] +job serveapi(unix:///var/run/docker.sock)
[/var/lib/docker|e0b714e0] +job initserver()
[/var/lib/docker|e0b714e0.initserver()] Creating server
2014/05/15 08:11:00 Listening for HTTP on unix (/var/run/docker.sock)
listen unix /var/run/docker.sock: bind: permission denied
[/var/lib/docker|e0b714e0] -job serveapi(unix:///var/run/docker.sock) = ERR (1)
2014/05/15 08:11:00 listen unix /var/run/docker.sock: bind: permission denied

@rvalyi
Copy link

rvalyi commented Jul 11, 2014

Hello,

I'm running into that "permission denied" issue with Docker version 1.1.1, build bd609d2
But my use case is Docker inside LXC: my Host is an Ubuntu Trusty, then I have a Vagrant LXC (Raring or Trusty) where I try to run Dokku and Docker.
I tried re-login, and could ensure root was in the docker group. So proposed solutions didn't make the cut for me.

But then I tried the same Vagrant configuration with Raring and the standard virtualbox provider instead of LXC, then Docker just worked...

If you want to try to reproduce, I just do Vagrant up with this Vagrant file:
https://github.com/fgrehm/chef-dokku/tree/test_kitchen_migration
(yes this test_kitchen_migration branch)
This works (eventually adding default['docker']['image_cmd_timeout'] = 3000 in attributes/default.rb in case of timeout)

If instead I modify the Vagrantfile to use config.vm.box = 'fgrehm/raring64-lxc instead of just raring64
and if I start with vagrant up --provider=lxc, then I run into the "permission denied issue" when the Dokku recipe tries to launch Docker (or if I SSH in the box and try manually).

Does this helps? cc @mitchellh @fgrehm

@jessfraz
Copy link
Contributor

What init system are you using?

@enricostano
Copy link

I'm getting the same too on a vagrant VM (ubuntu 14), I have to use sudo docker info to avoid the error...

@cdekok
Copy link
Author

cdekok commented Oct 27, 2014

The issue comes back with me too :(
Docker version 1.3.0, build c78088f

@mattupstate
Copy link

@mech7 same here

@cyroxx
Copy link

cyroxx commented Nov 3, 2014

@mech7 @mattupstate
On Ubuntu 14.04, I am also using the Docker version 1.3.0, build c78088f.

Adding myself to the docker group by sudo usermod -a -G docker <username> and rebooting (logout/login might have worked as well) did the job for me. I do not see the permission denied anymore when I issue docker commands.

@javiervivanco
Copy link

@cyroxx Thank you. It works!

@ssebastianj
Copy link

Adding myself to the docker group by sudo usermod -a -G docker <username> and rebooting (logout/login might have worked as well) did the job for me. I do not see the permission denied anymore when I issue docker commands.

Thanks!! It worked for me on Ubuntu 14.10 and Docker version 1.2.0, build fa7b24f

@rvanrijn
Copy link

@cyroxx Thank you. It works! I wasted a couple of hours...now I am happy :)

@jbruni
Copy link
Contributor

jbruni commented Jan 31, 2015

I also had to add my user to "docker" group, by sudo usermod -a -G docker <username>... Is this documented?

@jessfraz
Copy link
Contributor

yes multiple places, but here is one example
http://docs.docker.com/installation/ubuntulinux/#giving-non-root-access

On Sat, Jan 31, 2015 at 1:02 AM, J Bruni notifications@github.com wrote:

I also had to add my user to "docker" group, by sudo usermod -a -G docker
... Is this documented?


Reply to this email directly or view it on GitHub
#5314 (comment).

@sjayendran
Copy link

thank you @cyroxx! that worked!

@907th
Copy link

907th commented Mar 22, 2015

The @cyroxx 's solution works! It is explained in "Giving non-root access" section of official Docker docs.

jdivock added a commit to jdivock/docker that referenced this issue Apr 14, 2015
Without adding the user to the group you're going to hit nasty TLS errors. Figured I'd save the next guy the hassle.

Problem more accurately described here:
moby#5314
jdivock added a commit to jdivock/docker that referenced this issue Apr 14, 2015
Without adding the user to the group you're going to hit nasty TLS errors. Figured I'd save the next guy the hassle.

Problem more accurately described here:
moby#5314

Signed-off-by: Jason Divock <jdivock@box.com>
@meawoppl
Copy link

meawoppl commented May 9, 2015

The instructions here need a bump too:
https://docs.docker.com/installation/ubuntulinux/

It suggests the user change at the end of install, but following the install directions directly on 14.04 will eventually lead you to this issue post!

@psachin
Copy link

psachin commented Apr 13, 2016

@tianon Logout->Login sometimes is not appropriate, as we have process running. Any idea if this related to docker ? If yes, then it should be marked as bug.

@Mik1337
Copy link

Mik1337 commented Jan 24, 2017

Had the same problem, tried logging out and logging back in and that did not fix it, but when I rebooted my machine I did not get any errors running docker commands with my non-root use.

tl;dr: if logging out and logging back does not work, try rebooting

@saadaouad
Copy link

Thanks @cyroxx +1

@martiuh
Copy link

martiuh commented Feb 9, 2017

I added myself to the docker group, then I did log out and did log in, after that I checked if I was in the docker group

$ groups
adm cdrom sudo dip plugdev lpadmin sambashare docker
#I was in the group

But couldn't run docker run hello-world

I checked if the docker service was running

$ sudo service docker status
#Everything was fine, docker was active

What I did next was to restart the docker service with:
$ sudo service docker restart
after the restart I was able to do $ docker run without sudo, hope this helps someone 😃

@tahir-gvs
Copy link

tahir-gvs commented Feb 22, 2017

A side note: If you are trying to connect to socket from within a container, make sure you have the group docker defined within the container too.

$ docker exec -it yourcontainer bash
$ whoami
$ groups

If you see that docker group is not there in your container, edit /etc/group file to make an entry something like (see group file syntax)

docker:x:999:jenkins

Replace jenkins with container User. A container restart may be required after editing /etc/group file.

@2pay
Copy link

2pay commented May 2, 2017

You can fix this error by add you to docker group:

$ sudo usermod -aG docker $(whoami)
$ sudo usermod -aG docker your_username

when logout and login back

@armaandhir
Copy link

I have ubuntu as a vm. Did everything as mentioned above and even see docker in groups but still get this error.

@chinglinwen
Copy link

After adding user to the docker group, I find out that newgrp docker may work without logout and login. ( try id command to see the difference, the docker group will show up now. )

@bakmei
Copy link

bakmei commented Sep 23, 2018

You don't need to reboot. The reboot was to trigger the restart of the "docker.service". Therefore, you just need "sudo systemctl restart docker.service" I have test this on CentOS7 and it works. You still need to include the user in the group as mentioned above.

@delta-one-one
Copy link

FYI, the one thing I missed was that the docker group MUST be locally defined on the server in /etc/group - I am using OpenLDAP, and although everything looked fine, I still had the permission denied error until I did this.

@thaJeztah
Copy link
Member

@delta-one-one looks like that may be addressed by #38126 (once reviewed, tested, and merged)

@synergiator
Copy link

synergiator commented Dec 7, 2018

how to debug if after joining the group the persmission is still not present?

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/json: dial unix /var/run/docker.sock: connect: permission denied

Ubuntu 18.04 LTS, docker 18.09.0, build 4d60db4 (running on a real hardware; sudo mode works fine)

@cochiseruhulessin
Copy link

Same issue as @1605200517, same OS/docker version and on GCE instance. In my case, it seems to happen randomly.

@sam-cyglass
Copy link

@martiuh s solution was the thing I was missing.

$ sudo service docker restart

I didn't find it in the docs (not so deeper search though), shouldn't it be included there?

@aliceinwire
Copy link

@sam-cyglass I think yes it should.
Restarting docker did the trick

@ppazos
Copy link

ppazos commented May 11, 2020

I followed the post-installation instructions and worked for me:

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

IMPORTANT: after making changes, reboot.

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

No branches or pull requests