Docker - cannot connect to the Docker daemon - docker

I'm trying to start a new Docker container with:
docker run -it ubuntu /bin/bash
However I get the following
Checking for the daemon, I get
Any idea what the problem might be?

I had the same kind of problem couple of days ago on LINUX, try below command,use on sudo mode
sudo usermod -aG docker your_user_name
OR
sudo usermod -aG docker $(whoami)
then logout and log in.:) walla
For Mac : see https://stackoverflow.com/users/1978931/dayel-ostraco

I got this problem. In my case, ps showed that the docker daemon was not running. Problem was, I had no clue why.
$ sudo docker -d
attempts to start the daemon manually and displays an error message if it fails.
In my case, my kernel was a bit old and didn't support docker.
There are lots of reason why the daemon may not start, so it's best to find out if it's running and if not, why not.

Related

Bitnami Jenkins: Got permission denied while trying to connect to the Docker daemon socket

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.24/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
I'm getting this whenever I try to run Docker inside Jenkins. The machine was installed using the Bitnami Jenkins image. I have exhausted every troubleshooting option I can think of in an effort to solve what should be a simple permissions issue, but keep coming up empty.
I have attempted all the suggestions here at this Stack Overflow thread. I have attempted adding jenkins, bitnami, azureuser and anyone else on the system that looks like they might run Docker to the docker group using sudo usermod -a -G docker <user>.
I can sudo su - jenkins and docker run hello-world without issues.
Yet, still, no matter what I do, I am reduced to this error.
sudo usermod -aG docker $USER does nothing.
sudo usermod -a -G docker bitnami does nothing.
sudo usermod -a -G docker jenkins does nothing.
sudo usermod -a -G docker literallyanyusericanthinkof does nothing.
Rebooted/restarted hundreds of times now, no help.
I can run Docker in literally any other context on the machine, but Jenkins still refuses to run it. I am at my whits end getting this to work. I've configured at least two other Jenkins servers to do this before, but this one is giving me grief and I have no idea why.
Can anyone point me in the right direction?
So I don't necessarily feel good about this, but I ran into this issue today and I got around it by changing the ownership on the docker.sock file in /var/run to jenkins:docker and now my Jenkins is working. The command I ran was
sudo chown jenkins:docker /var/run/docker.sock
I'm not using Jenkins, but for my personal account, my method was similar to #benjaminpazienza above. I also don't feel great about it but it works.
sudo chmod 666 /var/run/docker.sock
I ran into the same problem, Jenkins restart didn't work as well.
I found that restarting the machine hosting the Jenkins will fix it. Avoid giving r/w access to others by chmod as much as you can.

Intellij Idea: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Even though my user is on docker group and I can launch docker without sudo, and I'm running idea.sh from my user, whenever I try to connect to docker from within Intellij Idea docker plugin, I get
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
I'm trying the Unix socket method. I already tried multiple restarts and logout.
I'm on Ubuntu 20.04 and Intellijd Idea 2020.3
Adding current user to docker group worked for me:
sudo gpasswd -a ${USER} docker
You might need to create group first:
sudo groupadd docker
restart your OS after those changes
For me it work
sudo chmod 0777 /var/run/docker.sock
Then test this in the terminal without the sudo
docker ps -a
normally you should have access to the docker process

Docker client under WSL2 doesn't work without sudo

On WSL2 (Ubuntu 20.04), I'm trying to connect to the Docker daemon that's running on Windows.
$ docker ps
Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?
(exit code 1)
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
(exit code 0)
Why does it work with sudo, but not without sudo? How can I make it work without sudo?
I have done
$ sudo usermod -aG docker $USER
which ran successfully, but didn't help with the issue.
I have also restarted everything many times, which didn't help.
Weird solution for this one - but go ahead and try:
unset DOCKER_HOST
And if that works, you can make the fix permanent by going back and commenting out the "export DOCKER_HOST=tcp://localhost:2375" in your .bashrc file. I think it has something to do with how docker is configured in WSL 2 vs. WSL 1, but Docker never updated their documentation to reflect this.
For me below commands worked (execute them in order)
sudo addgroup --system docker
sudo adduser $USER docker
newgrp docker
# And something needs to be done so $USER always runs in group `docker` on the `Ubuntu` WSL
sudo chown root:docker /var/run/docker.sock
sudo chmod g+w /var/run/docker.sock
Reference : https://github.com/rancher-sandbox/rancher-desktop/issues/1156#issuecomment-1017042882

Docker not working after installation

I tried installing the docker using the linux method.
However when the command $docker run hello-world is executed, it outputs:
docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
See 'docker run --help'.
What can be done about this?
First of all make sure the daemon is running:
$ps aux|grep "docker daemon"|grep -v "grep"
A) The daemon is not launched (no lines are returned by the ps)
Start the daemon that is not working:
$sudo /usr/bin/docker daemon -H unix:///var/run/docker.sock
Or start it as a service with:
$sudo /usr/sbin/service docker start
At this point the daemon is launched.
B) The daemon is launched
As shown by the ps with something like:
[..] /usr/bin/docker daemon -H unix:///var/run/docker.sock
You're good to go with your first container with a:
$sudo docker run hello-world.
sudo and docker
If you want to use docker without being sudo (this you should, though you must be aware of the security warning!) a good read of this will help you.
You have to run this command as sudo.
sudo docker run hello-world
This will give you enough privileges to perform that action.
If you want to enable your user to rung docker without sudo, then check out this answer.

Cannot connect to the Docker daemon. Is 'docker -d' running on this host?

I am trying to run my Docker commands, but I am facing the notification error in the title. I tried running:
ps auxww | grep docker
but still getting the error. Any solution?
If you can verify that the docker daemon is running then it may be that your user is not allowed to access docker.
To do this add yourself to the docker group.
sudo usermod -aG docker <userid>
Remember to do a re-login or otherwise apply/activate the new group permission.
newgrp docker
How about launching the daemon
sudo service docker start
should do the trick.
Or
sudo docker -d
In my case I had multiple docker instances running so it didn't know what to attach to. After killing them and restarting, my problem was solved.

Resources