I'm trying to run docker as a non-root user. When I try, I get the following error:
$ docker ps
FATA[0000] Get http:///var/run/docker.sock/v1.18/containers/json: dial unix /var/run/docker.sock: permission denied. Are you trying to connect to a TLS-enabled daemon without TLS?
I can run docker as root:
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[...]
I've put this user into a Unix group docker
:
$ groups
domain users docker suappprod stashadmin config_mgmt remote server access sudevmail sudevsvn
However, it still appears that this user cannot run most of the docker commands without sudoing as root.
I am on an older version of docker:
$ docker --version
Docker version 1.6.1, build a8a31ef/1.6.1
I know that the latest is 1.10, and it's possible for our company to update all of the docker installs to 1.9.2, but that will take a lot of effort and time.
Is there something else I need to look at? The user has been logged in and out multiple times. I have not rebooted the system yet.
My docker version is 17.06.1-ce, build 874a737 on Ubuntu 16.04.3 LTS
For linux distro that using
systemd
there is service nameddocker.socket
The file location is at
/lib/systemd/system/docker.socket
From that file we can change
SocketMode=0660
intoSocketMode=0666
Restart
docker.socket
Our docker socket permission will be
066
means every user can read and write into it.Every user can now run
docker
command as non-root user.Be aware of non-root access to docker command Why we don't let non-root users run Docker in CentOS, Fedora, or RHEL
Reference :
Adding users to the Docker group (since Docker group has full control to the socket)
As root, add the user to the docker group:
This is how I've been able to set it up on my Ubuntu systems time and time again.
Check what this command gives -->
ls -l /var/run/docker.sock
You may want to change the permissions of this file using chmod (Ex:sudo chmod 777 /var/run/docker.sock
) depending on what permissions you want to give.