Docker / Docker

Docker permission denied

Fix Docker permission denied errors when running docker commands or mounting files.

Category
Docker
Error signature
permission denied while trying to connect to the Docker daemon socket
Quick fix
Start Docker and make sure your user has permission to access the Docker daemon.
Updated

What this error means

Docker permission denied errors mean the Docker client, daemon, or container process tried to access a file, socket, or directory without enough operating system permissions.

Common causes

Quick fixes

  1. Confirm Docker is running:

    docker version
  2. On Linux, add your user to the Docker group:

    sudo usermod -aG docker "$USER"
  3. Log out and back in so the group change applies.

  4. Retry the Docker command.

Step-by-step troubleshooting

  1. Run docker info and check whether the daemon responds.
  2. Inspect /var/run/docker.sock ownership with ls -l /var/run/docker.sock.
  3. If the failure happens inside a container, check the container user with id.
  4. For bind mounts, compare host file ownership with the UID and GID used in the container.
  5. Avoid using sudo as a permanent workaround for development workflows; fix the daemon or file permissions instead.

FAQ

Is it safe to add my user to the Docker group?

Only do this on machines where you trust the user account. Docker group access is powerful and can effectively grant root-level control.

Why does the error happen only with volumes?

The container process may run as a different user than your host user, so mounted files can become unreadable or unwritable.

Does Docker Desktop need the docker group?

Usually no. Docker Desktop manages access differently on macOS and Windows.