How to fix docker permission denial error for rootless user while trying to connect to the Docker daemon socket ?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 7
  • Docker

Issue

  • Facing permission issues when running docker commands for rootless user
$ docker ps
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock

Resolution

  • Create a group called docker and add the rootless user to this group. Doing so will provide the user with the necessary permissions to execute docker commands.
  # groupadd docker

  # usermod -aG docker user_name
  • The user now needs to log off from all the logged in sessions and re-login so that the group memberships are reevaluated.

  • After logging in again, the user will be able to run docker commands without errors.

$ docker ps
CONTAINER ID     IMAGE     COMMAND     CREATED     STATUS     PORTS     NAMES

Root Cause

  • User is missing permissions to run docker commands and is forbidden from running it.

Diagnostic Steps

$ docker ps
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.26/containers/json: dial unix /var/run/docker.sock: connect: permission denied

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments