Unable to run Windows Container on Google Cloud - docker

I am trying to run a Windows container on Google cloud and get this error...
C:\Program Files\Docker\docker.exe: failed to register layer: re-exec error: exit status 1: output: ProcessUtilityVMImage \?\C:\ProgramData\docker\windowsfilter\0a04539f9f077acf8dbc35f493c70f4ba3f75a65aff70fd20281886b835c69ef\UtilityVM: The system cannot find the path specified.
There is utterly nothing wrong with the container. I have run the same container on my Windows dev box, on Azure and finally on AWS without any issues.
The Dockerfile looks like this...
FROM microsoft/dotnet-framework:4.7.2-runtime
WORKDIR /.
COPY License/ /License/
COPY Input/ /Input/
COPY Engine/ /Engine/
COPY redist/ /Engine/
COPY Scripts/ /
RUN mkdir Output
CMD ["powershell.exe","./runxx.ps1"]
I have created 3 VM instances on Google Cloud platform, first with 1803 Windows Server with containers, then 1709 Window Server with containers and finally Windows Server Datacenter 2016 Core.
1803 was a complete failure. The docker installed was running Linux containers. So when pulling the windows container you get the strange error "Unknown blob...". Took a while to figure this out. No way it seems to switch to windows containers via the command line.
UPDATE: I tried the 1803 image again and the Windows container runs fine now. Not sure what when wrong with the first 1803 VM I created. I am still wondering why I couldn't get Windows Server 2016 working.
I got further with 1709. Docker was running windows containers, but when I tried to run the container I got the error indicating that my docker image required Windows Server 2016.
So finally I built a VM with Windows Server 2016 Core. There is no container optimized version to I had to install Docker myself. I followed carefully the script https://cloud.google.com/compute/docs/containers/#docker_on_windows which includes quite a few ridiculous workarounds for known issues. Briefly you need to install docker with
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider
Then the work arounds for known issues...
netsh netkvm setparam 0 *RscIPv4 0
reg add HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters /v DisabledComponents /t REG_DWORD /d 0x0 /f
And after all this it still does not work and gives me the error reported at the top.
What am I doing wrong? I have to conclude that Google Cloud is simply not ready to run Windows containers.
EDIT: On further investigation I have determined that I can run a windows container built from Windows nanoserver but not one built from the full .NET Framework.
i.e. if my Dockerfile contains:
FROM microsoft/nanoserver
the container will run. If it contains
FROM microsoft/dotnet-framework:3.5-runtime
or
FROM microsoft/dotnet-framework:4.7.2-runtime
it will fail. Why is that? And where does this "failed to register layer" error come from?

Related

error during connect: This error may indicate that the docker daemon is not running in cmd

I am a beginner at Docker. I need to create two containers for mongo and mongo-express. But, I'm getting an error as error during connect: This error may indicate that the docker daemon is not running.
Then I tried below steps:
I run the cmd as administrator. Then I run the command "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchDaemon. It didn't work for me. then I tried with 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon way. Then I enabled hypervisor also. Still, I am getting the same error. When I ran the docker version command in cmd I received the below-mentioned outputs:
Then after I tried with cd "C:\Program Files\Docker\Docker" and ./DockerCli.exe -SwitchDaemon separately.
docker info command gives below mentioned error:
C:\Windows\system32>docker info
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., v0.10.0)
compose: Docker Compose (Docker Inc., v2.15.1)
dev: Docker Dev Environments (Docker Inc., v0.0.5)
extension: Manages Docker extensions (Docker Inc., v0.2.17)
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
scan: Docker Scan (Docker Inc., v0.23.0)
Server:
ERROR: error during connect: In the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect.: Get "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/info": open //./pipe/docker_engine: The system cannot find the file specified.
errors pretty printing info
Did you install the Docker Desktop on your Windows PC? If not please install it and Run it. If you already installed it, please run it first!
Then you can see whether the docker engine is starting or not!
After the docker engine started check whether this error is still there. Most probably error will fix after doing that!
If the docker engine is not started, please uninstall docker and delete everything from Registry.
Press Win+R and %appdata%\Docker to go and delete all the files.
Then reinstall the docker, if better you can install the docker desktop. Because with the docker desktop, the docker provides a whole bundle with it! Then you will be able to install the docker for windows smoothly.
Because this error usually getting when the docker engine is not started. Also, this may happen missing Linux kernel on windows. Both issues will address with the correct installation of the Docker Desktop.
You can check whether you have a docker Linux subsystem running on your windows pc by running the following command on cmd,
wsl -l
If you get a result like this,
C:\Users\gayan>wsl -l
Windows Subsystem for Linux Distributions:
docker-desktop-data (Default)
docker-desktop
Then you are okay and ready to go.
If not, please try to uninstall and install the docker desktop
Make sure you delete the previous registry, To do that press Win+R and type Regedit Then go to HKEY_LOCAL_MACHINE -> SOFTWARE -> Docker Inc and delete that folder.
If still you are getting the same error, try to troubleshoot the docker desktop. you can refer to the docker documentation.

error during connect: This error may indicate that the docker daemon is not running

I am new to Docker and after writing docker version in cmd I got this error,
error during connect: This error may indicate that the docker daemon is not running.: Get "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/version": open //./pipe/docker_engine: The system cannot find the file specified.
The following steps solved this problem:
Open cmd as administrator
Launch command: "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchDaemon
some times docker might be disabled from starting on boot or login so in the windows search bar or when clicking the WinKey and starting to type Dock... like showen in the picture below, Then press Enter to start the Docker Daemon
Try running dockerd in a separate terminal and then try running this command.
To avoid doing this every time you can go to services -> find Docker -> select Startup Type as Automatic (Delayed) and reboot the machine.
Simple Solution: Just open Powershell and type dockerd which will start the daemon and you shall be able to use the docker now without errors.
On Windows, reason behind this issue is that Docker is not started. I tried couple of solution provided on multiple online portal to start it. What worked for me is:
In Docker Desktop if you are already logged in as a user, logout from there
Again login to docker desktop with docker account
When we login to docker account, it internally triggers the restart. So resulting if it's not started, it will start the docker for us.
I had this, but when I used a command shell elevated to Administrator, docker version was fine.
This error may indicate that the docker daemon is not running.: Get "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json": open //./pipe/docker_engine: The system cannot find the file specified.
this error in windows 10
step 1
pls install (https://learn.microsoft.com/en-us/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package) Download the latest package:
this link WSL2 Linux kernel update package for x64 machines
then restart then automatically running
In my case,
I download the this github repo.MaxySpark
Closed all the application related to docker.
1.Click on docker.reg file in the downloaded repo.
2.Click on yes->yes->ok to merge.
3.Again open the Docker Toolbox and run docker run hello-world
Open cmd as administrator
Launch command: C:\Program Files\Docker\Docker\DockerCli.exe -SwitchDaemon
It simply means that your docker application is not running or you have not logged in to docker application, or docker desktop service is not running .
1: Just open Docker desktop application, login with docker credentials.
2: if already logged in and still getting this error, go to windows + r ==> and type 'services.msc', and restart the docker desktop service.
All done.
It can be kernel problem:
You need to update WSL2 Linux kernel update package for x64 machines
Follow this tutorial:
https://linuxhint.com/resolve-docker-daemon-not-running/
and before execute "docker run hello-world" command, dont forget restart docker
https://learn.microsoft.com/en-us/windows/wsl/install-manual

Not able to start docker Desktop in Windows

I am not able to start the Docker container in Microsoft Windows 10 profession. As I found the cause of this error is due to the docker engine is failing to start.
After installing docker I am able to run only the docker version command.
-> docker --version
As I found the error which is showing docker daemon is not running in windows while running any other docker commands on CMD.
I also enabled (checked) the Hyper-V option in "Turn Windows features on or off" in the Control panel -> Programs -> Turn Windows features on or off.
The error is related to the daemon part:
In the default daemon configuration on Windows, the docker client must be run elevated to connect.
We can switch the Docker daemon as an elevated user in order to run the docker daemon in the Windows professional:
Run below command with Windows Powershell as administrator:
Run the PowerShell command: -
& 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon
OR
You can run the below command on CMD as administrator:
Run the CMD command: -
"C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchDaemon
My Docker Desktop failed to start after I forced it to exit while updating (it stuck during the update that's why I had to do it). No solution on the Internet helped me until I ran into this Powershell command:
wsl -l -v
It listed the following:
* Ubuntu-18.04 Stopped 2
docker-desktop Uninstalling 2
docker-desktop-data Stopped 2
It kept saying "Uninstalling" even after rebooting the whole system.
What I did was:
wsl -t docker-desktop
It terminated docker-desktop and made the problem gone.
delete %appdata%\Docker\settings.json and let Docker to create a new one
You should check WSL:
Execute "wsl -l -v" at the command prompt.
If the result is like this:
Then execute "wsl --shutdown" on the command line.
Then execute "wsl -l -v", you will see:
Then start Docker Desktop.
This solved my problem.
Make sure to download the Linux Kernel Update Package and then try restarting Docker Desktop.
Download from here
Just share my experience how I solved the problem with "docker failed to start" or similar problem. I found some mess with my Win10 Home edition, despite the fact that all checkes regarding Hyper-v, wsl and others passed I got failed to start docker engine. So, I tried to install one of the old version (4.4.4), not the newest one. An voila it installed wsl2 and started without any problems!
Hope this could help someone who's tried all solutions (for example, deletion of the %appdata%\docker folders) :)
I was getting the same exact issue and a solution was provided from thread The attempted operation is not supported for the type of object referenced." error after Windows Update fixed my problem. I had tried everything before this solution. To keep it simple just follow the below steps -
Copy below snippet
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\0408F7A3]
"AppFullPath"="C:\Windows\System32\wsl.exe"
"PermittedLspCategories"=dword:80000000
Save it as a file wsl.reg
Execute the file to update the wsl registry
restart docker desktop
these steps are basically done to do some changes in the registry of wsl distribution that is installed standalone or by docker.
Using PowerShell gave me a right direction. All restarts and re-install with deletion didn't work.
wsl -l -v showed list of three processes but wsl -t docker-desktop responded with "There is no distribution with the supplied name." only. wsl --shutdown either didn't work.
Solution is next door wsl --unregister docker-desktop . After this all went fine.
I ran the following command which resolved the issue for me.
wsl --unregister docker-desktop
Please make sure your OS type requires WSL or Hyper-V to run docker as per this official link ๐Ÿ‘‰ https://docs.docker.com/desktop/install/windows-install/
For my case, I am using Windows 11 Home OS, and it requires WSL (Windows Subsystem for Linux) to run docker. So that I installed WSL on my system.
Follow this link to install WSL ๐Ÿ‘‰ https://learn.microsoft.com/en-us/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package
After that restart your system, then open docker (It may take up to 10 secs to start)
Hope it may solve your issueโœŒ๏ธ

Linux container on server 2019 machine

I created a docker image on my red hat Linux .
The base image is a centos image and has a application installed on it. I am able to run the image on dockers on multiple Linux machines .
I then saved the image and then copied the image on windows server 2019 machine with all latest updates installed .
I then loaded the image using
docker load -i img.tar
When I try to run the container I get the following error
PS C:\Users\manish\Desktop\docker> docker run -dit --name manish22ct docker_22_oct:1.0
99d061211a5cc682408a2556946266e0df2596f3a4d233a557d99e28cd24371e
C:\Program Files\Docker\docker.exe:
Error response from daemon: container 99d061211a5cc682408a2556946266e0df2596f3a4d233a557d99e28cd24371e encountered an error during CreateContainer:
failure in a Windows system call: The virtual machine or container JSON document is invalid. (0xc037010d)
extra info: {"SystemType":"container","Name":"99d061211a5cc682408a2556946266e0df2596f3a4d233a557d99e28cd24371e","Owner":"docker","LayerFolderPath":"C:\\ProgramData\\docker\\lcow\\99d061211a5cc682408a2556946266e0df2596f3a4d233a557d99e28cd24371e","Layers":[{"ID":"cf1935b5-650d-57cc-81f0-469ceb110edf","Path":"C:\\ProgramData\\docker\\lcow\\04f407aadd6912e3bc76dcd858a2754acbf5a378ccef8a11ec1079c070900a4e\\layer.vhd"},{"ID":"fe9ae0e9-ed92-51ea-b423-098275f00ed8",
Answering my own question to the best of my ability in case it helps someone .
I found that the docker daemon for Linux and windows are different. For Linux
its provided by dockerhub but for windows its provided by Microsoft . Some images I downloaded from dockerhub like Cassandra doesn't work directly on windows too but run perfectly fine on Linux .
Sometimes these images run too .
In case you image is not running on both there is something in your image layer that is hindering your run on windows .
For windows I found that RUN command is something you should avoid .
Check your dockerfile and remove all RUN commands and move all those in to a shell file say runMe.sh. At the end of all your commands in this shell file don't forgot to include tail -f /dev/null
Since only one CMD is allowed in dockerfile
CMD ( /runMe.sh > /runMe.log 2>&1 )
is the only thing that would remain of RUN and CMD set of instructions in your dockerfile .
Create your image . It would run on both Windows and Linux .

Can I run Docker on GCP?

The scenario is that I'm trying to get a Bamboo installation up on google cloud.
I had it set up on Linux, but NuGet is busted and refuses to authenticate with the server even though the same auth works on windows. I have a ticket open with them.
In the meanwhile, I decided to try setting it up on Windows since I know NuGet will work properly there, and it turns out it does. So I'm halfway through setting up a test build and it's now time to build a docker image. In order to do so, I need to install docker, right? So I do, but it won't start because Moby won't start. I'm assuming it's because you can't nest VMs. So now I'm stuck.
Somehow, AppVeyor has docker running in their images, but I don't know what their underlying infrastructure is.
So does anyone know if I can get docker running enough to build container images on Windows Server 2016?
You can follow this documentation guide which walks you through the steps to setup Docker on a Windows Server 2016 and later versions which include container support:
Install Docker:
Connect to the Windows Instance.
Open a PowerShell terminal as an administrator.
Install Docker from the Microsoft repositories:
PS C:> Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
PS C:> Install-Package -Name docker -ProviderName DockerMsftProvider
Run the following commands to work around known issues with Windows containers on Compute Engine:
Disable Receive Segment Coalescing:
PS C:> netsh netkvm setparam 0 *RscIPv4 0
Enable IPv6:
PS C:> reg add HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters `
/v DisabledComponents /t REG_DWORD /d 0x0 /f
Restart the instance:
PS C:> Restart-Computer -Force
Follow the additional steps as described in the provided documentation above.
Yes you can do it using Kubernetes Engine
Kubernetes Engine is a managed, production-ready environment for deploying containerized applications. It brings our latest innovations in developer productivity, resource efficiency, automated operations, and open source flexibility to accelerate your time to market.
Kubernetes Engine supports the common Docker container format. (So you can run docker on Kubernetes Engine )

Resources