# Fixing the Docker Permission Denied While Trying to Connect to the Docker Daemon Socket Error

DevFeed: [Fixing the Docker Permission Denied While Trying to Connect to the Docker Daemon Socket Error](<https://devfeed.tech/articles/fixing-the-docker-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket-error-28158.md>)

Original publisher: [Read original article](<http://fuzzyblog.io/blog/docker/2020/06/10/fixing-the-docker-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket-error.html>)

Author: Fuzzygroup

Published: 2020-06-10T00:00:00Z

Content type: tutorial

Language: en

Sources: [Scott Johnson](<https://devfeed.tech/sources/scott-johnson.md>)

Topics: [Docker](<https://devfeed.tech/topics/docker.md>), [Ubuntu](<https://devfeed.tech/topics/ubuntu.md>), [Ansible](<https://devfeed.tech/topics/ansible.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>)

Tags: [ansible](<https://devfeed.tech/tags/ansible.md>), [docker](<https://devfeed.tech/tags/docker.md>), [id](<https://devfeed.tech/tags/id.md>), [linux](<https://devfeed.tech/tags/linux.md>), [permission](<https://devfeed.tech/tags/permission.md>), [ubuntu](<https://devfeed.tech/tags/ubuntu.md>)

## AI overview

This tutorial explains how to fix Docker permission errors when connecting to the Docker daemon socket on Ubuntu. It recommends adding the user to the docker group, logging in again, and verifying group membership with the id command, and includes an Ansible task for applying the change.

## Source excerpt

I recently had the situation where even the simplest docker command: docker run -it bash gave this error: docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/create: dial unix /var/run/docker.sock: connect: permission denied. See 'docker run --help'. The solution for this is actually pretty simple: Add your user to the docker group. Since I was running Ubuntu linux, the default user is also ubuntu and then command is: sudo usermod -aG docker ubuntu And then you have to log out and log back in or u -s ${ubuntu} Here's an ansible task which you can drop in a playbook to accomplish this: - name: Update the ubuntu user to be part of the docker group user: name: ubuntu shell: /bin/bash groups: docker append: yes Verifying this If you need to validate what groups a user is in then use: id -nG ubuntu Note: Thanks to Don Neufeld for teaching me this command; somehow despite N decades of unix experience, I missed the id command. Bizarre. See Also Here's a good article from Digital Ocean on this.