Skip to content

Instantly share code, notes, and snippets.

@sgarciav
Last active October 16, 2023 16:02
Show Gist options
  • Save sgarciav/6f30495f5904dc105a9edf90a5cea0fc to your computer and use it in GitHub Desktop.
Save sgarciav/6f30495f5904dc105a9edf90a5cea0fc to your computer and use it in GitHub Desktop.
Docker without sudo

About

When you first install Docker, you have to execute its commands with sudo. Follow these steps to add your user to the docker group such that there won't be a need to execute with sudo.

Steps

  • 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.

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