DockerJunior
Docker commands only work with sudo
On Linux the Docker socket belongs to root and the docker group. Add your user to the group, or use rootless mode, and mind the security cost.
What you see
dockerworks withsudobut fails without it- After adding yourself to the group:
WARNING: Error loading config file: /home/user/.docker/config.json - stat /home/user/.docker/config.json: permission denied
What it means
The Docker daemon listens on a Unix socket that root owns. Other users can only use it through sudo, unless they are in the docker group, because the daemon creates the socket so members of that group can reach it.
Be clear about the cost. The docs warn that the docker group grants root-level privileges to the user.
How to confirm the cause
- 1See which groups you are in
id
Look for
dockerin the list. Group changes only apply to new login sessions.
Causes and fixes
Your user is not in the docker group
- HOW TO TELL
iddoes not listdocker.- FIX
- Create the group if it does not exist, add your user, then log out and back in. In a VM you may need to restart it. You can also run
newgrp dockerto pick up the change in the current shell.sudo groupadd docker sudo usermod -aG docker $USER newgrp docker docker run hello-world
~/.docker has the wrong owner after running docker with sudo
- HOW TO TELL
- The config.json permission denied warning above.
- FIX
- Remove
~/.docker/(it is recreated, but custom settings are lost), or fix its owner and permissions.sudo chown "$USER":"$USER" /home/"$USER"/.docker -R sudo chmod g+rwx "$HOME/.docker" -R
How to stop it coming back
- Run Docker as a non-root user with rootless mode if the root-level access of the docker group is not acceptable in your environment.
- Do not mix
sudo dockerand plaindockeron the same machine.
Keep going
- Runbook: Cannot connect to the Docker daemon
- Cheat sheet: Docker
- Cheat sheet: Linux Permissions
- Lesson: the containers topic in Learn
Sources
Docker documentation (docs.docker.com), read 18 Nov 2026 from the official docs repository.