Skip to content

Instantly share code, notes, and snippets.

@kevmo
Last active January 27, 2023 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevmo/22e5e36ee897a23156050c28703f266d to your computer and use it in GitHub Desktop.
Save kevmo/22e5e36ee897a23156050c28703f266d to your computer and use it in GitHub Desktop.
# Run 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

If you are on Ubuntu 14.04-15.10, use docker.io instead:

$ sudo service docker.io restart

source material

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment