Math-Linux.com

Knowledge base dedicated to Linux and applied mathematics.

Home > Linux > Tip of the day > Got permission denied while trying to connect to the Docker daemon (...)

Got permission denied while trying to connect to the Docker daemon socket

You run docker run hello-word and you get permission denied while trying to connect to the Docker daemon socket ...
How to fix this ?


You run docker run hello-word and you get:
Got permission denied while trying to connect to the Docker daemon socket
How to fix this ?

Did you forget sudo ?

Check if you do not forget sudo

mathlinux@osboxes:~$ sudo docker run hello-word

Does your user belong to docker group ?

Add docker group if it does not exist:

mathlinux@osboxes:~$ sudo groupadd docker

Check it:

mathlinux@osboxes:~$ getent group docker
docker:x:141:

Here, user mathlinux is not on docker group. Add it like follows and restart docker engine:

mathlinux@osboxes:~$ sudo usermod -aG docker ${USER}
mathlinux@osboxes:~$ getent group docker
docker:x:141:mathlinux
mathlinux@osboxes:~$ sudo systemctl restart docker

Since you add this user to docker group, you do not need to use sudo:

mathlinux@osboxes:~$ docker run hello-word

Is it enough ?

The Docker daemon can listen for Docker Engine API requests via three different types of Socket: unix, tcp, and fd.

By default, a unix domain socket (or IPC socket) is created at /var/run/docker.sock, requiring either root permission, or docker group membership. So try to check that docker group is allowed to read/write:

mathlinux@osboxes:~$ ls -al /var/run/docker.sock 
srw-rw---- 1 root docker 0 Oct 12 12:35 /var/run/docker.sock

It it is not:

mathlinux@osboxes:~$ sudo systemctl stop docker
mathlinux@osboxes:~$ sudo chown root:docker /var/run/docker.sock
mathlinux@osboxes:~$ sudo chown chmod 660
mathlinux@osboxes:~$ ls -al /var/run/docker.sock
srw-rw---- 1 root docker 0 Oct 12 12:38 /var/run/docker.sock
mathlinux@osboxes:~$ sudo systemctl start docker
mathlinux@osboxes:~$ docker run hello-word

Also in this section

  1. Crontab : Scheduling Tasks
  2. Time a task: time
  3. Download music and videos .mp3, .wma, .avi, .mpg , divx with google
  4. How to change the MAC address on Linux
  5. Comment changer son adresse MAC sous Linux
  6. How to Convert Text File From ISO-8859-15 to UTF-8 Encoding
  7. SVN — How to ignore file or directory in subversion?
  8. How to setup SSH timeout in shell script ?
  9. phpMyAdmin: Search and Replace in MySQL database
  10. How to encrypt/decrypt a file or directory in Linux?
  11. Find list of options that python was compiled with
  12. Check/find version of numpy i’m using
  13. Speedup GNU make build and compilation process
  14. How to make a denial of a service with fork functions in BASH ?
  15. Find out biggest cpu/memory consuming processes with ps command
  16. Intel compilation for MIC architecture KNL Knights Landing
  17. GNU compilation for MIC architecture KNL Knights Landing
  18. Archiving and compressing data files tar
  19. Linux How to delete or remove printer from command line
  20. Linux How to connect to Windows with remote desktop RDP in CentOS 7 / RedHat 7
  21. SVN — Branch, Branching subversion howto
  22. How to diff remote files using ssh ?
  23. Generating a self-signed certificate using OpenSSL with Linux CentOs/RedHat for Apache/httpd
  24. Got permission denied while trying to connect to the Docker daemon socket