Skip to content

Instantly share code, notes, and snippets.

@Marcelektro
Created January 26, 2025 10:32
Show Gist options
  • Save Marcelektro/6ce52178f8f2cd1045ad59e776c101c5 to your computer and use it in GitHub Desktop.
Save Marcelektro/6ce52178f8f2cd1045ad59e776c101c5 to your computer and use it in GitHub Desktop.
How to use docker without sudo?

Use Docker without sudo

To use docker without sudo, you need to be in the group docker.
Read the Docker docs: https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user

Here's what to do:

1. Check if the group exists by trying to create it.

If it doesn't, you'll need it anyway, so just run:

sudo groupadd docker

You'll most likely get this response:
groupadd: group 'docker' already exists

2. Add yourself to the group

sudo usermod -aG docker $USER

The variable USER stores your username in your current shell session.
If you want to add some other user, just replace $USER string with their username.

3. Apply changes, by either starting a new shell session (e.g. logout and log back in via SSH) or by simply logging into the new group via:

newgrp docker

Now, you should be able to run docker commands without root privileges! :D

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