Can't use Docker due to insufficient rights
Issue
A user reports that using Docker on his Linux machine is not possible. Any docker
command that the user executes returns an error message similar to the one below.
Example output:
$ docker ps
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock:
dial unix /var/run/docker.sock: connect: permission denied. See 'docker run --help'.
Solution
Info
Unprivileged users that are not already members of the docker
system group cannot communicate via the Docker daemon socket without root permissions. This is why the docker
commands that depend on this socket fail and return an error message.
To fix the issue, simply add the user to the docker
system group with the command below and replace <USERNAME>
with the actual username.
Warning
This command can only be executed by the helpdesk
, ctop
and root
users
$ sudo usermod -aG docker <USERNAME>
After that you can ask the user to either run the command below or restart his login session, so that the new group membership can take effect.
$ newgrp docker
Once the steps have been completed successfully the user should be able to use Docker as intended.