Article Background
Back to Knowledgebase

How to Run Docker Commands Without Sudo on Ubuntu Linux

VPS
Cubes Support
July 20, 2026

By default on Ubuntu and Debian Linux, the Docker daemon binds to a Unix socket owned by the root user. As a result, non-root users must prefix every Docker command (docker ps, docker run, docker-compose up) with sudo.

If you prefer executing Docker commands directly without typing sudo every time, you can add your system user to the docker group.

This quick guide will show you how to create the docker group, add your user, and verify non-sudo Docker access on your Cubes Hosting Linux VPS.


Step 1: Create the docker User Group

On most modern Docker installations, the docker group is created automatically. You can ensure it exists by running:

sudo groupadd docker

(If the group already exists, the terminal will report groupadd: group 'docker' already exists).


Step 2: Add Your User to the docker Group

Add your current Linux user account to the docker group using usermod:

sudo usermod -aG docker $USER

(The $USER variable automatically selects your currently logged-in SSH username).

Adding a Specific User: If you want to grant non-sudo Docker access to another user (such as a developer account named deploy), replace $USER with their username:
sudo usermod -aG docker deploy


Step 3: Activate Group Membership Changes

Linux caches user group memberships when you log in. To apply the new group membership immediately without logging out of SSH, run:

newgrp docker

Alternatively, you can disconnect your SSH session (exit) and log back in.


Step 4: Verify Non-Sudo Docker Access

Test that your user can run Docker commands without sudo by running the official test container:

docker run hello-world

If successful, Docker will download the test image and display:

Hello from Docker!
This message shows that your installation appears to be working correctly.

Now try inspecting active containers:

docker ps

If docker ps outputs container headers without permission errors, you're all set!


Security Consideration Note

IMPORTANT: Adding a user to the docker group grants them equivalent root-level access on the host system, because Docker containers can mount host directories (like /etc/ or /root/). Only add trusted system users and developers to the docker group!


Conclusion

Granting non-root access to the Docker daemon takes less than a minute. Add your user to the docker group, activate it with newgrp docker, and manage your containerized applications seamlessly on your Cubes VPS!

Special Offer

Ready to Start Your Server?

Get 10% OFF your first month on any server with promo code CUBES10 at checkout!

24/7 Assistance

Need Help With Your Server?

Already a Cubes Hosting customer and couldn't find your answer? Our dedicated support team is available 24/7.