I’ve just installed docker but I have to run it with sudo every time. If I don’t add sudo I get the following error:
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/json: dial unix /var/run/docker.sock: connect: permission denied
Is there a way around that? I want to be able to run docker without having to type my password each time…
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hello,
According to the official Docker docs here:
https://docs.docker.com/install/linux/linux-postinstall/#manage-docker-as-a-non-root-user
You need to do the following:
To create the docker group and add your user:
This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.
If you initially ran Docker CLI commands using sudo before adding your user to the docker group, you may see the following error, which indicates that your
~/.docker/
directory was created with incorrect permissions due to the sudo commands.~/.docker/
directory (it is recreated automatically, but any custom settings are lost), or change its ownership and permissions using the following commands:Here’s also a quick video demo on how to do this:
Hope that this helps! Regards, Bobby
The above is almost right, but opens up a security gap that let’s everyone get access to docker.sock
Instead of
sudo chmod 666 /var/run/docker.sock
which opens it to everyone, entersudo chown root:docker /var/run/docker.sock
That way root still has it’s connection with docker but anyone in the docker group gets access too.
If you run into this:
Try this: sudo apt install gnupg2 pass
See this github answer for details: https://github.com/docker/cli/issues/1136#issuecomment-459649905