PyCharm Cannot Connect to Docker, thinks the Docker daemon is not running - docker

The PyCharm interface to Docker has suddenly stopped working on my Mac. When I try to connect to Docker I get the error message "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?".
Docker appears to be working correctly. docker info returns reasonable results. The Docker Desktop is running. I can start a container through Docker Desktop and connect to it. Kibana works. The only thing that looks odd is that /var/run/docker.sock does not exist.
Is it a problem that docker.sock does not exist?
The PyCharm configuration for Docker looks like this:
I haven't changed it since everything worked.
A common solution suggested online it to change the permissions on the /var/run/docker.sock file, but obviously I can't do that. There is an assortment of things to try, but most of them require sudo and I don't have admin privileges on this machine. There is a Stack Overflow question that describes the same situation, but there the problem was that Docker could not be run without sudo, which is not the case here.
What is particularly strange is that this was working just a few days ago, and as far as I know nothing on the machine has changed. Same PyCharm setup, same Docker, same OS. I'm on
Python Community Edition 2021.2.3
Docker version 20.10.22, build 3a2c30b
Mac OSX Ventura 13.1
I have tried restarting the system.
Any ideas on what is broken?

The problem was that /var/run/docker.sock did not exist.
More details are in this Docker support forum thread.
This fix was to create the following softlink:
ln -s ~/.docker/run/docker.sock /var/run/docker.sock

Related

Docker does not autostart every time

Running Ubuntu desktop as server as a VM on ESXI and have Docker running there and Home assistant.
The problem is - When power source breaks, the machine autorestarts, VM reboots, but docker does not always boot up and Home assistant doesn't work either.
When I type in
sudo docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running
Then I got to ESXI - hit restart and all works like a charm.
What can it be guys?
You need to enable the docker service to run it automatically when the system restarts. The command is:
sudo systemctl enable docker
thank you, i tried that and got this line
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
i guess this should help me out.
but i still don't understand why it autostarted sometimes, and sometimes not

Docker in WSL2: Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?

I am currently running a Debian Distro (The default one from the Microsoft Store) on WSL 2 and I am having a lot of trouble with running Docker on it. My OS currently is Windows 10 Education Insider Preview, version 2004, and the os build is 19587.1000 and I have Docker Desktop.
Now, at this point, I've literally tried everything. I have tried using the "Expose daemon on tcp://localhost:2375 without TLS" way to no result. Then, I tried enabling "Enable the experimental WSL 2 based engine" (this is also why I had to move to Windows 10 education and get docker desktop and move to this version 2004).
I have also commented out "#export DOCKER_HOST=tcp://localhost:2375" from my .bashrc.
And then since WSL does not support systemd nor systemctl, starting docker using these are useless, and thus I tried "sudo service docker start" and also "sudo /etc/init.d/docker start". But, still when I run any command in Docker in my WSL, it gives me this:
$ docker ps -a
Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?
I just can't seem to figure out what is wrong...
I've looked up everywhere, tutorials, forums, other questions on StackOverFlow.
Most are either about Docker on Native Linux or on WSL 1 where they use the first method of exposing the daemon on tcp://localhost:2375 without TLS which is not very secure, but I didn't even get that working on mine.
Please help! It would be greatly appreciated!!
Thanks in advance!
https://github.com/docker/for-win/issues/5096
Make sure youve upgraded your wsl distro to v2 by checking wsl -l -v in windows powershell
In docker settings, Use the WSL 2 based engine & Enable WSL integration for your distro
But what finally fixed it for me was overriding the DOCKER_HOST env variable left over from using WSL1
export DOCKER_HOST=unix:///var/run/docker.sock
You can execute this line to test and then add it to your .bashrc and make sure its not getting set in .bash_profile or.profile
You should then be able to run docker ps successfully
Ok so basically I installed a clean WSL. This time I got a clean Ubuntu, and somehow it fixed the issue. My other WSL distros still won't work with this, but this clean Ubuntu does. However, as soon as I installed some stuff on it, it started breaking again. Now, I reinstalled it and now it works fine. Seems like something could be potentially conflicting with this?
Okay, I am using WSL2 + Ubuntu + Docker Desktop. What fixed the issue for me waschecking the option "Expose daemon on tcp://localhost:2375 without TLS" in Docker Desktop.
I had a similar issue on Debian, which was strange, as I had a running instance of OpenSUSE connecting to and using docker without problems.
In my case the reported error was
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
WSL2 Integration was enabled for both instances.
What eventually worked was the following:
From within both WSL Debian and WSL.exe - unset DOCKER_HOST
Restart Docker... (right-click on the Docker Dashboard icon in Task Bar)
Try any docker command again or just plain docker ps
There is an option for exposing the daemon on tcp://localhost:2375 without TLS, however it is unchecked by default, and I left it that way.
Enabling virtualization technology in the bios settings worked for me.

Can not run docker command on windows 7

can not run docker on windows7 command after installation, and there is nothing in virtualbox.
I have tried uninstall and install other versions, run install application administrately and try another dirver but above does not work.
...
when installation finished, i clicked the docker quickstart terminal, and it show me this error message:
dial tcp 127.0.0.1:53822: connectex: No connection could be made because the tar
get machine actively refused it.
Looks like something went wrong in step ´Checking if machine default exists´...
Press any key to continue...
Just a reminder, there are sort of 3 ways to use docker on Windows, if one doesn't work you may want to try another one:
use docker Desktop: it requires windows 10 Pro (In fact Hyper-V maybe it's an option for you)
use docker Toolbox: the one you may have installed on windows 7, it uses Virtualbox and a docker machine VM.
use Virtualbox directly: install a linux distribution with shared folder only for your docker usage
Now since you are on option 2, you should have a virtualbox installed, so you can check if the underlying docker machine is launched by launching virtualbox, it should list the installed vm.
If the vm is not started: you will have to search the problem on virtualbox side, error logs or popup: trying to launch the vm manually directly from virtualbox application will help you
If the vm is started: there may be a connection problem between your host (windows) and your vm (boot2docker), you could try to connect to the vm via bash using "boot2docker ssh" as it is indicated in the quick start. If it works, the connection problem could come from a firewall.
Check if the quick start happened correctly when you have luanched it.
I don't want to make proselitism on other solution, but it may be simpler to use a linux directly in virtualbox (option 3), at least at the beginning to get more familar with docker.
The other simpler option would be to use windows 10
I'm sorry it's not a complete solution, but indications, and it was too long for a comment.
docker server is not running properly. check is you can run docker ps or docker version command successfully.

docker daemon exec: "dockerd" : executable not found in %PATH%

I'm trying to run this command :
docker daemon --insecure-registry 192.168.99.100:5000
but i'm gettin ghe following error:
exec: "dockerd": executable file not found in %PATH%
I'm using win7 and docker-toolbox 1.12.2 with VM Virtual Box.
What is the problem here?
there is a way to run this command?
That is indeed what issue 27102 report:
Docker Daemon command dockerd not found on latest stable Docker for Mac and Docker Toolbox
(this is for mac but also applies on Windows)
Docker for Mac should probably print a different message, also, we may need to check if the CLI is on the same "host" as the daemon, and print a different message based on that (as running dockerd wont work if the daemon is on a remote server).
the daemon runs in a Linux virtual machine, so you do not need to (and cannot) run it manually. It is already running of the whale is in the top bar.
Conclusion: (Aug. 2021):
I'm closing this ticket, because the current behaviour is as expected.
I think this was originally opened when the docker cli still had a daemon subcommand (during the transition from a single binary to separate binaries for the cli and daemon), which is no longer the case.
The dockerd binary, which is the docker daemon, is not available for macOS (and unlikely will be), because it's a Linux binary that (on Docker Desktop for Mac) runs inside the Docker Desktop VM.
In 2022:
I'm having this exact same issue on the most recent MacOs version (Monterey, Version 12.3.1 (21E258)).
I've uninstalled Docker & reinstalled several times, if I run docker ps or docker run hello-world as paulinechi describes, I get that same error:
docker: Cannot connect to the Docker daemon at `tcp://35.215.110.128:2375`.
Is the docker daemon running?...
Answer:
Make sure you don't have a DOCKER_HOST environment variable set; from that error, it looks like either you have a DOCKER_HOST env-var, or possibly a docker context that defines a non-standard location to connect to the daemon.
The default should be to connect with the Engine API using a unix-socket (unix:///var/run/docker.sock)
Confirmation:
I forgot I was pointing to a DOCKER_HOST on a remote machine that has since shut down.

Connect to Windows 10 Docker daemon from Ubuntu Bash

I'm trying to do something fairly non-standard, so I'm not sure how successful I'm going to be.
I've installed "Docker for Windows", and I'm able to use it fine from PowerShell.
I would like to be able to use a proper Linux environment though, so I've installed the new Ubuntu Bash prompt for Windows 10.
I've successfully built the latest Docker client in Ubuntu/Bash. However when I run "docker ps", I get:
Cannot connect to the Docker daemon. Is the Docker daemon running on this host?
I had hoped that it might just work.
Is it possible to connect to a Docker daemon running in Windows from Ubuntu/Bash?
I figured it out. It was surprisingly simple. I just had to set the following...
export DOCKER_HOST=tcp://127.0.0.1:2375
This is actually a really cool setup.
A very fast, efficient Docker engine running in a type 2 hypervisor, and a proper Ubuntu-based development environment. Nice :-)
Notice: as #BSalita mentioned in the comment, the Docker service must be running with "Expose daemon on tcp://localhost:2375 without TLS" enabled, which can be found in the general section in Docker Settings (right click on the system tray icon then "Settings..."). This option is not checked by default.

Resources