Docker does not autostart every time - docker

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

Related

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

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

Can't get past "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?" Error on Windows

I am a Windows user trying to run "docker-compose up" command but continue to get the error in title. I am writing this code in Ubuntu using WSL 2.
I have tried everything - from this post to this post - and have made sure I have docker installed correctly. When I run "sudo service docker start" I get "docker: unrecognized service". I'm thinking of switching to Podman (though would prefer not to if can avoid it) to get past having to use the docker daemon- though I can't seem to get this to run in wsl.
Any and all guidance would be appreciated!
This typically means that your Docker Service is not running.
Open RUN and type services.msc, then click OK or hit enter
Search for service named as Docker Desktop Service.
Make sure it is running.
You can also set the Docker service to start when you login from Docker Desktop GUI setting panel

Trying to start the kubernetes in Docker-Desktop but it's stuck

Update
The issue is resolved.
I shutdown docker desktop.
Deleted C:\ProgramData\DockerDesktop and .kube folder
Restarted docker desktop
reset docker desktop to factory defaults
and restarted it again and it worked.
I have started learning Kubernetes and Dockers yesterday. I installed Docker-Desktop today and my docker container is running. When i check the enable kubernetes option on Docker-Desktop it's not running. It just shows me a loading and below it just shows kubernete starting.
Photo of my Docker Desktop
What i have tried:
Uninstalling Docker Desktop and reinstalling it
Reset Kubernetes Cluster
Reset to Factory default
I have tried other solutions too which i found here on stackflow like:
Running it as an Administrator
Run this on powershell and then try to start kubernetes
[Environment]::SetEnvironmentVariable("KUBECONFIG", $HOME + "\.kube\config", [EnvironmentVariableTarget]::Machine)
But None of the solutions is trying to fix the problem im having.
Addition Information:
Im running Docker Desktop on Windows 10 pro
Docker Version: 2.2.0.5 Kubernetes version: v1.15.5
I fixed it!
I deleted the config file i.e ~/.kube/config then I uninstalled the app through the Troubleshoot window. I reinstalled and enabled kubernetes which required the internet to download the necessary files and after a while kubernetes was running. I believe its due to the internet connection during the installation of kubernetes files that causes problems.
Your update is right. That's what worked for me (on Windows 10) :
Shutdown Docker Desktop
Delete .kube folder (path : C:\Users\YourUserName\.kube)
Restart Docker Desktop
Reset Docker Desktop (press the scarab button (or also, debug or troubleshoot button) and click on "Reset to factory defaults")
Shutdown Docker Desktop
Restart Docker Desktop
Now, in the settings and in Kubernetes tab, Enable again Kubernetes (Check "Enable Kubernetes" option)
That's what worked for me and hope it's gonna be useful for you.
Just follow these steps
stop docker for desktop
remove the folder ~/Library/Group\ Containers/group.com.docker/pki
rm -rf ~/Library/Group\ Containers/group.com.docker/pki
start docker for destkop
Found the solution here
And given that every time I try to start "Docker for Desktop" Kubernetes get stuck, to better investigate for me was useful remove the kube autostart from the configuration.
Just edit the file:
~/Library/Group\ Containers/group.com.docker/settings.json
And change kubernetesEnabled value to false
Steps to follow :
Quit Dockerdesktop
remove ~/.kube/config
And ~/.kube/cache/*
restart start the docker desktop.
If you are behind a corporate vpn. then make sure you are able to configure proxy for the internet access in docker destop in preferences->Proxy. or you can disconnect from vpn and let the kubernates cluster setup for the first time. After that you can configure the proxy.

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.

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