Menu
User

DropVPS Team

Writer: Cooper Reagan

How to use Docker without sudo?

How to use Docker without sudo?

Publication Date

04/13/2025

Category

Articles

Reading Time

2 Min

Table of Contents

Running docker with sudo every single time gets old really fast. If you’re on Linux and you’ve installed Docker, chances are you’ve already bumped into this:

$ docker ps
Got permission denied while trying to connect to the Docker daemon socket...

Yeah, annoying. But don’t worry — there’s a proper fix for this that doesn’t involve bad security practices like setting Docker to run as rootless in unsafe ways. Here’s how you can run Docker commands without needing sudo.

Step 1: Add Your User to the Docker Group

Docker runs as a daemon with root privileges, and by default, only users in the docker group can interact with it without sudo.

To add your user:

sudo usermod -aG docker $USER

What this does is append your current user to the docker group. This tells the system, “Hey, this person can access Docker without asking for root privileges every time.”

Step 2: Log Out and Log Back In

This part is easy to forget — but important. The group change won’t take effect until you log out and log back into your session.

If you’re in a hurry and don’t want to log out completely, you can just run:

newgrp docker

This updates your group membership in the current shell. After that, try again:

docker ps

If all went well, it should work without sudo.

Step 3: Test It Out

Try pulling an image and running a quick container:

docker run hello-world

If it runs and prints out the welcome message without asking for sudo, congrats — you’re good to go.

Optional: Verify Your Group Membership

If you want to double-check you’re in the right group, just run:

groups

You should see docker listed among your groups. That’s it. clean, secure, and no more typing sudo docker every time. If you’re managing Docker containers frequently, this tweak will save you time and improve your workflow.

Linux VPS
U
Loading...

Related Posts

How to use Docker without sudo?