Why is the Docker service stopping? - windows

I'm running Ubuntu as a subsystem on Windows 10.
I have just followed the steps to install Docker on Linux:
https://docs.docker.com/install/linux/docker-ce/ubuntu/
And are now at the step to test the hello-world app:
$ sudo docker run hello-world
Where I get this error:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
I have narrowed it down to that it actually is the service that is not running - despite lots of other solutions online that more or less fixes this type of error.
When I check the status:
$ sudo service docker status
* Docker is not running
It says it's not running so I start it successfully:
$ sudo service docker start
* Starting Docker: docker [ OK ]
If I check the status immediately it says it's running. But when I check it again a few second later, it's not runnning:
$ sudo service docker status
* Docker is running
$ sudo service docker status
* Docker is not running
Why is the Docker service stopping and how can I keep it running?

What you got is as expected.
Microsoft does not support running the Docker daemon (also known as the service) within the WSL instance. You can refer to this discussion.
What you can do is just use docker client in WSL to connect to a remote docker engine which means docker daemon still on other PC.
But, if you use WSL2 which announced in May 6th, 2019, then, from microsoft's announcement, it could be(There is also a demo in this announcement which you can have a look):
Today we’re unveiling the newest architecture for the Windows Subsystem for Linux: WSL 2! Changes in this new architecture will allow for: dramatic file system performance increases, and full system call compatibility, meaning you can run more Linux apps in WSL 2 such as Docker.

You need either Docker on Windows:
https://medium.com/#sebagomez/installing-the-docker-client-on-ubuntus-windows-subsystem-for-linux-612b392a44c4

Related

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? (Ubuntu 20.04 ,WSL2)

I have Microsoft Windows 10 Pro version 10.0.19041 N/A Build 19041 and I follow steps here https://learn.microsoft.com/en-us/windows/wsl/install-win10 to install Ubuntu 20.04 LTS on it using WLS2 , I'm doing so to install docker by following steps here https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository
but when I try to run sudo docker run hello-world it gives me this error docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'. I know that a similar question asked here Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running? ,and I try to run systemctl daemon-reload and systemctl start docker but al the solutions does not worked for me it gives me another errors like System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down and Also try to fix it but I can't, So I need your help.
Note : I have already install Docker in windows and It works fine.
I have been solving this problem by following these steps
Purge the Grub package Linux command according this issue https://github.com/microsoft/WSL/issues/4903
Stop Docker Desktop from Windows
Run sudo dockerd which is the daemon service for Docker containers
https://i.stack.imgur.com/qgbwE.png
Open new Ubuntu shell session
Run docker run hello-world
and it's work fine with me https://i.stack.imgur.com/6TJ3u.png

Unable to connect to Docker daemon WINDOWS

I've installed Stable Docker Desktop for WINDOWS 10. I tried running:
docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
So it appears that it can connect to Docker daemon. However when I run my own command:
C:\Users\cortex>bash
DESKTOP-2GHN95P:/tmp/docker-desktop-root/mnt/host/c/Users/cortex/# cortex deploy
I get following error:
error: unable to connect to the Docker daemon
please confirm Docker is running, or if Docker is not installed, install it by following the instructions for your operating system: https://docs.docker.com/install
I'm new to Docker and I can't figure out this problem. Anyone has any ideas?
Looks like you're trying to run cortex from a WSL, which is trying to take action on the docker engine in the host OS. If you have WSL 2, you can enable the WSL 2 integration for Docker desktop in the settings. If that's not an option, you can always install docker on your WSL instead,

docker installation on Windows

I have installed Docker in my windows 10 machine.
When i open power-shell and check docker version it shows below
PS C:\Users\XXXXX> docker --version
Docker version 19.03.4, build 9013bf5
But when i ran Docker images or docker run it did not worked
PS C:\Users\XXXXX> docker images
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/images/json: open
//./pipe/docker_engine: The system cannot find the file specified. In the
default daemon configuration on Windows, the docker client must be run elevated to connect. This
error may also indicate that the docker daemon is not running.
For Docker run
PS C:\Users\XXXX> docker run hello-world
docker : C:\Program Files\Docker\Docker\Resources\bin\docker.exe: error during connect: Post
http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/containers/create: open //./pipe/docker_engine: The
system cannot find
the file specified. In the default daemon configuration on Windows, the docker client must be run
elevated to connect. This error may also indicate that the docker daemon is not running.
I am not getting if docker is installed then why docker images and docker run are not working ?
Make sure the Docker service is runnig.
(1) Go to Services.
(2) Check service Docker for Windows is running.
You can stop/start the service as well using below commands in command prompt.
Net stop com.docker.service
Net start com.docker.service
Refer article : https://success.docker.com/article/docker-for-windows-fails-with-a-daemon-not-running-message
Have you manually started docker after the installation?
Install Docker Desktop on Windows

Windows does not support privileged mode

I am using Windows Subsystem for Linux. and I have problems creating a container.
docker-compose run --rm --service-ports --use-aliases backend - bash
Show me this error
ERROR: Cannot create container for service backend: Windows does not support privileged mode
I have activated
"experimental": true
If you have, in parallel of WSL, a Docker for Windows installed, with the option "Enable Linux Containers on Windows" (LCOW)" active (as in nodeshift issue 127, that could explained the error message (seen in moby#runconfig/hostconfig_windows.go)
Double-check your settings, following the "Setting Up Docker for Windows and WSL to Work Flawlessly"
While the Docker daemon cannot run directly on WSL, you can use the Docker CLI to connect to a remote Docker daemon running through Docker for Windows or any other VM you create.
Check also your Windows 10 version: the more recent, the better.

Docker can not run on Windows 10 linux child system

I just install the Windows 10 Anniversary update which has a new feature that linux child system. So I try to run docker in Windows 10 ubuntu bash(linux child system). Why I want to install docker in linux child system is because:
Windows 10 native docker 1.12 need Hyper-V, but Vmware couldn't run if Hyper-V enable. I have a lot images created by Vmware, it isn't so easy to switch to Hyper-v
I don't want to use Docker Toolbox, it need install VirtualBox, just redunant.
apt-get is fine, docker install success, but fail to start.
$ sudo service docker start
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
* Starting Docker: docker [ OK ]
$ docker ps
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
I have seen this post can-you-run-docker-natively-on-the-new-windows-10-ubuntu-bash-userspace, some people says that it is no posible to run docker in such linux child system, but there also some contrary opinions.
So, I want to ask is there any way to walk around this? Or I have to wait MS update this child system(since it is still beta now).
You have two Problems in there:
the linux child system does not provide the upstart service like e.g. ubuntu. You can work around this by running the docker deamon directly in foreground with docker daemon ...
This does nearly shure not work because docker requires features of the linux kernel like namespaces and capabilities. I don't think the NT-Kernel does implement such exotic features.

Resources