Fix Docker “Got permission denied issue”

Posted: | Last updated: | less than 1 minute read

This blog shows you, How to fix docker ‘Got permission denied while trying to connect to the Docker daemon socket’. To run docker as non-root user then you need to add it to the docker group.

The Docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo. The Docker daemon always runs as the root user.

Following are the steps to fix the permission denied issue.

  1. Create the docker group.
    $ sudo groupadd docker
    
  2. Add your user to the docker group.
    $ sudo usermod -aG docker $USER
    
  3. Log out and log back in so that your group membership is re-evaluated. If testing on a virtual machine, it may be necessary to restart the virtual machine for changes to take effect.
    $ docker images
    

Reference link: https://docs.docker.com/install/linux/linux-postinstall/#manage-docker-as-a-non-root-user