Skip to content

Instantly share code, notes, and snippets.

@joseluisq
Created September 12, 2017 16:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joseluisq/4a08752b662e9c459dd8bc5d715b8726 to your computer and use it in GitHub Desktop.
Save joseluisq/4a08752b662e9c459dd8bc5d715b8726 to your computer and use it in GitHub Desktop.
Manage Docker as a non-root user (without sudo)

Manage Docker as a non-root user

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. If you don’t want to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.

  • Add the docker group if it doesn't already exist:
sudo groupadd docker
  • Add the connected user $USER to the docker group. Change the user name to match your preferred user if you do not want to use your current user:
sudo gpasswd -a $USER docker
  • Either do a newgrp docker or log out/in to activate the changes to groups.
  • You can check if you can run docker without sudo:
docker run hello-world

Source: https://askubuntu.com/a/477554

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