I installed Docker in my machine where I have Ubuntu OS. After than I installed docker, when I run
sudo docker run hello-world
All it's ok, but I want to hide the word sudo
to make more short the command.
If I write the command without the word sudo
docker run hello-world
That display the following:
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.35/containers/create: dial unix /var/run/docker.sock: connect: permission denied.See 'docker run --help'.
It's happened the same when I try to make
docker-compose up
How can I resolve this?
I solve this error with the command :
lightdm and kwallet ship with a bug that seems to not pass the supplementary groups at login. To solve this, I also, beside
sudo usermod -aG docker $USER
, had to comment outto
in
/etc/pam.d/lightdm
before rebooting, for the docker-group to actually have effect.bug: https://bugs.launchpad.net/lightdm/+bug/1781418 and here: https://bugzilla.redhat.com/show_bug.cgi?id=1581495
After Docker Installation on Centos. While running below command I got below error.
Change Group and Permission for docker.socket
Verify by using below docker command
Seriously guys. Do not add Docker in your groups or modifies the socket posix (without a hardening SELinux), it's a simple way to make a root privesc. Just add an alias in your .bashrc, it's simpler and safer as : alias dc='sudo docker'.
docker
group/var/run/docker.sock
This fix my problem.