---
title: "Troubleshooting Docker Permission Denied Problems"
description: "If you're running into errors like docker permission denied, use this tutorial as your troubleshooting guide!"
canonical: "https://adamtheautomator.com/docker-permission-denied/"
---

# Troubleshooting Docker Permission Denied Problems

> If you're running into errors like docker permission denied, use this tutorial as your troubleshooting guide!

Source: https://adamtheautomator.com/docker-permission-denied/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Troubleshooting Docker Permission Denied Problems](https://adamtheautomator.com/wp-content/uploads/2021/10/Troubleshooting-Docker-Permission-Denied-Problems.jpg)

# Troubleshooting Docker Permission Denied Problems

[![](https://secure.gravatar.com/avatar/1117c2efdf8de21446d7ab331de2a85cb0b9b13ce18b09d9f7bc369451f2ce77?s=192&d=mm&r=g)Ekekenta Odionyenfe .C](https://adamtheautomator.com/author/ekekenta-odionyenfe/)13 October 20215 min. read

Categories: [DevOps](/category/devops/)

Tags:[Docker](/tag/docker/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Running Elevated Docker Commands](#running-elevated-docker-commands)
*   [Restarting the Docker Engine](#restarting-the-docker-engine)
*   [Adding User Account to a Group with Non-Root User Access](#adding-user-account-to-a-group-with-non-root-user-access)
*   [Editing the Docker Service Unit File](#editing-the-docker-service-unit-file)
*   [Running Docker in Privilege Mode](#running-docker-in-privilege-mode)
*   [Conclusion](#conclusion)

Running applications with Docker as a daily routine can become a nightmare when you run into an error such as Docker permission denied while trying to connect. But don’t worry, this article will help you get back running in no time.

In this tutorial, you will learn many ways to resolve the dreaded Docker permission denied error message.

## Prerequisites

This tutorial comprises hands-on demonstrations. To follow along, be sure you have the following in place:

*   The demos in this tutorial run on Ubuntu 20.04, but other Linux distributions will also work.
*   The [Docker](https://docs.docker.com/engine/install/ubuntu/) engine, with the tutorial running version 20.10.8, build 3967b7d.

## Running Elevated Docker Commands

Many factors could lead to a _permission denied_ error while connecting to Docker. One of those factors is that you may be running Docker commands without prepending the [`sudo`](https://www.sudo.ws/) command. The `sudo` command is what gives you elevated administrative rights along with security privileges when running commands.

Below, you can see the dreaded _permission denied_ error while trying to run a `docker` command.

![Running into a permission denied error ](https://adamtheautomator.com/wp-content/uploads/2021/10/image-130.png)

Running into a permission denied error

Launch your terminal and prepend `sudo` to the `docker` command below to [`run`](https://docs.docker.com/engine/reference/run/) the `hello-world` Docker image. Since you’re running an elevated command, you’ll need to enter your password to proceed.

```bash
sudo docker run hello-world
```

You’ll see an output similar to that shown below that indicates that Docker is installed correctly.

![Running Elevated (sudo) Docker Commands](https://adamtheautomator.com/wp-content/uploads/2021/10/image-131.png)

Running Elevated (sudo) Docker Commands

## Restarting the Docker Engine

If running elevated Docker commands does not fix the _permission denied_ error, verify that your [Docker Engine](https://docs.docker.com/engine/#:~:text=Docker%20Engine%20is%20an%20open,and%20instruct%20the%20Docker%20daemon) is running. Similar to running a `docker` command without the `sudo` command, a stopped Docker Engine triggers the _permission denied_ error. How do you fix the error? By restarting your Docker engine.

Run the [`systemctl`](https://www.man7.org/linux/man-pages/man1/systemctl.1.html) command below to confirm the Docker Engine’s status (`status docker`) and if it’s running.

```bash
sudo systemctl status docker
```

Below, you can tell the Docker Engine is running from the returned status that shows a**ctive (running).**

![Displaying Docker Engine status](https://adamtheautomator.com/wp-content/uploads/2021/10/image-132.png)

Displaying Docker Engine status

If the Docker Engine isn’t active, run the `systemctl` command below to start the Docker Engine (`start docker`).

```bash
sudo systemctl start docker
```

Now, run the hello-world Docker command as you did in the “Running Elevated Docker Commands” section to verify that the error is resolved.

```bash
sudo docker run hello-world
```

## Adding User Account to a Group with Non-Root User Access

You’ve confirmed your Docker engine is working, but you’re still getting a Docker _permission denied_ error? If so, you need to add your user account to a group with non-root user access. Why? Because any Docker command you run on a Linux machine not in the user group triggers _permission denied_ error.

1.  Run the [`groupadd`](https://man7.org/linux/man-pages/man8/groupadd.8.html) command below to create a new group called `docker`. Enter your password to continue running the command.

```bash
sudo groupadd docker
```

If the docker group exists in the user group, you will see an output like the one below.

![Creating a New Group Named 'docker'](https://adamtheautomator.com/wp-content/uploads/2021/10/image-133.png)

Creating a New Group Named ‘docker’

2\. Next, run the [`usermod`](https://man7.org/linux/man-pages/man8/usermod.8.html) command below where the `-aG` options tell the command to add your user account (`programmer`) to the (`docker`) group. This command causes your user account to have non-user access.

```bash
sudo usermod -aG docker programmer
```

3\. Run the [`newgrp`](https://linux.die.net/man/1/newgrp) command below to change the current real group ID to the `docker` group.

> _Run this command each time you want to run Docker as a non-root user._

```bash
sudo newgrp docker 
```

4\. Finally, rerun the hello-world Docker image to confirm that you no longer see the error. If, at this point, you’re still getting an error, then consider giving more access to the [docker.sock file](https://www.educative.io/edpresso/var-run-dockersock). The _docker.sock_ file is the UNIX socket, a way to communicate process information between the user and the system, that the Docker daemon listens to as the Docker API’s entry point.

Run the [`chmod`](https://man7.org/linux/man-pages/man1/chmod.1.html) command below to grant all users read/write (`666`) access to the `/var/run/docker.sock` file. Now run the hello-world Docker image again to see if the error is resolved.

Related:[A Windows Guy in a Linux World: Users and File Permission](https://adamtheautomator.com/linux-file-permissions/)

```bash
sudo chmod 666 /var/run/docker.sock
```

## Editing the Docker Service Unit File

If running Docker as a non-root user is not enough to fix the error, try editing the Docker SystemD, a service control system, service unit file. The Docker service file contains sensitive parameters that may alter the behavior of the Docker daemon. You can modify the Docker unit file’s default behavior by adding an extra command to change the service default behavior.

1\. Run the command below to open the Docker service unit file in your favorite text editor. For this example, the Docker service file opens in the nano text editor.

```bash
sudo nano /usr/lib/systemd/system/docker.service
```

2\. Locate the area with the **\[Service\]** header inside the Docker service unit file, as shown below. Copy/paste the commands below to the Docker service unit file and save the changes.

Below, the `SupplementaryGroups` command sets the supplementary Unix groups to where the processes are executed. At the same time, the `ExecStartPost` command cleans up operations that are executed even if the service fails to start up correctly.

```bash
SupplementaryGroups=docker    
ExecStartPost=/bin/chmod 666 /var/run/docker.sock
```

![Editing the Docker Service Unit File](https://adamtheautomator.com/wp-content/uploads/2021/10/image-134.png)

Editing the Docker Service Unit File

3\. Now, run the commands below to restart and enable the Docker service. Doing so lets you start the Docker service anew to avoid getting errors when you run Docker commands.

```bash
# Reloads all the Docker unit files and recreates the entire dependency tree.
sudo systemctl daemon-reload
# Restarts the Docker service
sudo systemctl start docker
# Enable the Docker to run on your computer.
sudo systemctl enable docker
```

4\. Finally, rerun the `hello-world` Docker image and see if you still get the permission denied error.

## Running Docker in Privilege Mode

Last but not least, on the list of fixing the Docker permission denied error is running Docker in [privileged mode](https://docs.docker.com/engine/reference/run/). Doing so grants a Docker container root access to the system.

> _Running Docker in privileged mode is risky and vulnerable to attacks from hackers. So be cautious and only run the Docker in privileged mode when you know exactly what you’re doing._

1\. Run the command below to list all Docker containers in your system, and get the ID of the container you want to run.

```bash
sudo docker ls -a
```

![Listing all Docker Containers in the System](https://adamtheautomator.com/wp-content/uploads/2021/10/image-135.png)

Listing all Docker Containers in the System

2\. Next, run the [`docker inspect`](https://docs.docker.com/engine/reference/commandline/inspect/) command below to check if the container you want to run is already in privileged mode (`--format='{{.HostConfig.Privileged}}'`). Replace `CONTAINER_ID` below with the actual container ID that you took note of in step one.

```bash
docker inspect --format='{{.HostConfig.Privileged}}' CONTAINER_ID
```

If the container is in privileged mode, the command returns a **true** value to the console. But if the command returns a false value, as shown below, move on to the next step.

![Checking if a Container is in Privileged Mode](https://adamtheautomator.com/wp-content/uploads/2021/10/image-136.png)

Checking if a Container is in Privileged Mode

3\. Finally, run the `docker` command below to `run` the Docker container in privileged mode (`--privileged hello-world`).

```bash
sudo docker run --privileged hello-world
```

## Conclusion

Throughout this tutorial, you’ve learned many ways to solve the Docker _permission denied_ error, from running elevated commands to running Docker in privileged mode.

Now you know how to rid of an error when building Docker-powered [applications](https://adamtheautomator.com/docker-image-prune/); perhaps you also want to keep your Docker images clean at all times?

Related:[Keep Your Docker Images Manageable with Docker Image Prune](https://adamtheautomator.com/docker-image-prune/)

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fdocker-permission-denied%2F&text=Troubleshooting%20Docker%20Permission%20Denied%20Problems)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fdocker-permission-denied%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fdocker-permission-denied%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2026/02/featured_image-13.webp)

### [Azure Container Apps: Instant Preview Environments per PR](/build-ephemeral-preview-environments-every-pr/)

Build isolated preview environments for every pull request using Azure Container Apps revision labels and Azure DevOps pipelines with scale-to-zero economics.

![](https://adamtheautomator.com/wp-content/uploads/2025/11/55418e927e511ae263219c072e27d637c2a967a5036de7020b329582db775c26.png)

### [Automating Docker Container Health Checks with Python and Local Notifications](/docker-health-checks-python/)

Docker's built-in health checks are passive—they tell Docker when a container fails, but do they tell you? In this tutorial, we'll build a lightweight Python monitoring system that runs entirely on your infrastructure with zero external dependencies. You'll learn to detect container failures in real-time, send instant alerts, and maintain a complete audit log of every state change.

![](https://adamtheautomator.com/wp-content/uploads/2023/07/gitea-docker.jpg)

### [Gitea Docker: Your Ultimate Self-Hosted Git Solution](/gitea-docker/)

Learn how to install a Gitea Docker instance and self-host Git repositories securely in this ATA Learning tutorial!

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
