How to fix Docker, Got permission denied issue
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
When working with Docker, encountering a "permission denied" error can be frustrating. This error typically means that your Docker client isn't allowed to access the Docker daemon due to insufficient permissions. This article provides a comprehensive look at why this happens and how you can fix it.
Understanding Docker’s Permission Denied Issue
Docker operates using a client-server architecture. The Docker client talks to the Docker daemon, which does the heavy lifting of building, running, and managing Docker containers. The error usually occurs when the Docker client does not have permission to communicate with the Docker daemon.
This issue frequently arises under these scenarios:
- User not in the Docker Group: The Docker daemon can run as a Unix socket which is owned by
root:docker. If your user is not part of thedockergroup, you're likely to face permission issues. - Misconfigured Docker Daemon: Sometimes, the Docker daemon may be configured to listen on a TCP socket without proper ACLs, making access problematic.
- Running Docker without Sudo: On most installations, Docker requires
sudoto function correctly unless a user is added to the Docker group.
Steps to Fix the Permission Denied Issue in Docker
1. Adding your user to the Docker group
You can add your user to the Docker group with the following command:
Note: After running this command, you must log out and back in for the group changes to take effect.
2. Check if Docker Daemon is running
Ensure that the Docker daemon is running using:
If it's not running, start it:
3. Adjusting Docker Daemon configuration
If Docker is configured to use a TCP socket (for example, for remote access), verify that your configuration appropriately secures the socket with SSL and firewall rules. Alternatively, reconfigure Docker to use Unix socket with appropriate user/group ownership.
4. Using Docker without Sudo
If you prefer not to use sudo every time you run Docker, ensure your user is added to the Docker group as described above. If permission issues persist, restart the Docker service to ensure all configurations are reloaded and applied:
5. Verify Permissions on Docker Socket
The Docker socket (/var/run/docker.sock) should typically own by root in the docker group. Check permissions using:
The output should be similar to:
If the group is incorrect, correct it using:
Summary Table
| Issue Potential | Command or Check | Purpose/Outcome |
| User not in Docker group | sudo usermod -aG docker $USER | Adds user to Docker group to avoid using sudo |
| Docker daemon not running | sudo systemctl status/start docker | Ensures Docker daemon is running |
| Misconfiguration in TCP socket | Verify /etc/docker/daemon.json settings | Ensures Docker daemon uses secure connections |
| Permissions on Docker socket | ls -l /var/run/docker.sock | Checks if Docker socket has correct permissions |
Troubleshooting Tips
- After making changes to user groups or daemon configuration, rebooting your system may be helpful to ensure changes take effect system-wide.
- Ensure SELinux (Security-Enhanced Linux) or other security modules are not interfering with Docker operations.
- Always pull the latest version of Docker and its dependencies to avoid bugs that might be causing permission issues.
Addressing the "permission denied" issue in Docker involves ensuring proper user permissions, correctly configuring the Docker daemon, and verifying that Docker's socket file has the correct ownership. Following the steps outlined above should help resolve most instances of this problem.
Related reading
- How to fix Docker Permission denied
- How to fix the WARNINGs when running the redisalpine Docker image
- How to force delete a Kubernetes Namespace?
- How to force Docker for a clean build of an image
- How to fix Error executing DDL alter table events drop foreign key FKg0mkvgsqn8584qoql6a2rxheq via JDBC Statement
- How to fix Headers already sent error in PHP
- How to force Docker for a clean build of an image
- How to force 'docker login' command to ignore existing credentials helper?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.