Skip to content

Instantly share code, notes, and snippets.

@ariefrahmansyah
Last active February 11, 2018 08:54
Show Gist options
  • Save ariefrahmansyah/c0de629f1fabba6d8d32e2644b47a97b to your computer and use it in GitHub Desktop.
Save ariefrahmansyah/c0de629f1fabba6d8d32e2644b47a97b to your computer and use it in GitHub Desktop.
Manage Docker as a non-root user

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 use docker run hello-world to check if you can run docker without sudo.


Source:

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