using Docker without sudo

Have you seen 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.24/containers/create": dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

Run Docker commands without sudo

1. Add the docker group if it doesn’t already exist
sudo groupadd docker
2. Add the connected user $USER to the docker group

Optionally change the username to match your preferred user.

sudo gpasswd -a $USER docker

IMPORTANT: Log out and log back in so that your group membership is re-evaluated.

3. Restart the docker daemon
sudo service docker restart

Leave a Reply

Your email address will not be published. Required fields are marked *.