How to Fix Docker Permission Denied Error on Linux

Docker

By Jennifer Webb

Updated on Jul 02, 2026

How to Fix Docker Permission Denied Error on Linux

Learn how to fix the Docker permission denied error on Linux with simple step by step instructions. Add your user to the Docker group, fix Docker socket permissions, and run Docker without using sudo.

If you run a Docker command and see an error like this:

docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock

This is one of the most common Docker issues on Linux.

The error usually means your Linux user does not have permission to communicate with the Docker daemon. The good news is that you can fix it in just a few minutes.

Step 1: Verify the Error

Run any Docker command.

docker ps

If you receive a permission denied error, continue with the steps below.

Step 2: Check Whether the Docker Group Exists

Docker creates a group named docker during installation.

Run:

getent group docker

If you see output similar to this, you're good to go.

docker:x:999:

If nothing is returned, create the group.

sudo groupadd docker

Step 3: Add Your User to the Docker Group

Run the following command.

sudo usermod -aG docker $USER

This gives your current user permission to access the Docker daemon without using sudo.

Step 4: Apply the Changes

Instead of rebooting your system, refresh your current session.

newgrp docker

If this doesn't work, simply log out and log back in.

Step 5: Verify Your User Belongs to the Docker Group

Run:

groups

You should see something similar to:

user sudo docker

If the docker group is listed, your permissions have been updated successfully.

Step 6: Test Docker Again

Now run:

docker ps

If Docker returns the container list instead of a permission error, the problem has been fixed.

You can also test with Docker's sample container.

docker run hello-world

If the Error Still Exists

Check Docker Socket Permissions

View the Docker socket.

ls -l /var/run/docker.sock

A healthy configuration looks similar to this.

srw-rw---- 1 root docker ...

If the socket belongs to a different group, correct it.

sudo chown root:docker /var/run/docker.sock
sudo chmod 660 /var/run/docker.sock

Restart Docker afterward.

sudo systemctl restart docker

Then test again.

docker ps

Fix Docker Configuration Permission Issues

Sometimes the problem is caused by files inside your Docker configuration directory, especially if Docker commands were previously executed with sudo.

Check the directory.

ls -ld ~/.docker

If it is owned by root, change it back to your user.

sudo chown -R $USER:$USER ~/.docker
sudo chmod -R g+rwx ~/.docker

Now try running Docker again.

docker ps

Verify Docker Service Is Running

If Docker is not running, you'll continue to see errors.

Check its status.

sudo systemctl status docker

If it is stopped, start it.

sudo systemctl start docker

Enable Docker to start automatically after every boot.

sudo systemctl enable docker

Temporary Fix

If you need to run a Docker command immediately, you can use:

sudo docker ps

This works, but it is only a temporary solution. Adding your user to the Docker group is the recommended long term fix.

Avoid This Common Mistake

You may find articles recommending this command:

sudo chmod 777 /var/run/docker.sock

Do not use it.

This makes the Docker socket accessible to every user on the system, which creates a serious security risk. The correct solution is to add your user to the Docker group instead.

Conclusion

The Docker permission denied error is almost always caused by missing user permissions. In most cases, adding your user to the docker group, refreshing your session, and verifying the Docker service is running will solve the problem. If the issue continues, checking the Docker socket and your local Docker configuration usually identifies the remaining cause.