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 .
Related
I'm quite new to Docker. I'm running on Windows 10 Enterprise and am trying to containerize an existing app that runs on windows (so it's a Windows container). I don't know if this matters but the container is rather large (8 GB).
I need to share a config file (that lives on the host) with the container that the app will use when starting. I was thinking that a bind volume was simplest.
Problem: On running the image I get docker: Error response from daemon: invalid volume specification: '<source path>:<target path>'
Container was built with this command:
docker build -t my_image .
Here is the Dockerfile:
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8
WORKDIR /app
COPY . .
ENTRYPOINT .\application.exe ..\Resources
Here is what I've tried
docker run -it -v c:/Users/my_user:/app my_image
I've tried every combination of C:/, C:\, C:\\, /c/, //c/, \c\, \\c\, etc.
I've tried multiple combinations of /app, //app, \app, \app, C:\app, etc.
I've also tried with and without :rw appended to the end
I've tried the ```--mount``` syntax which consistently outputs: docker: Error response from daemon: invalid mount config for type "bind": invalid mount path: '/app'. (tried a bunch of variations of /app here too)
I've tried every possible combination (except the right one). Please help!
Since you are using a Windows container, your file path will change. Try the below command, from the docs Persistent Storage in Windows Containers
docker run -it -v c:\Users\my_user:c:\app my_image
If you are using a powershell and trying to run docker using docker run command you can try this approach. It worked for me in windows powershell (vs code powershell)
docker run -v ${pwd}\src:/app/src -d -p 3000:3000 --name react-app-c2 react-app-image
Here react-app-c2 is container name and react-app-image is image name
-v is for volume and ${pwd} is for current working directory
/app/src is for the containerdirectory.
I have the following basic Dockerfile:
FROM mcr.microsoft.com/windows/servercore:1903
CMD echo Hello World!
When I run the command:
docker build -t latest . or docker build .
My terminal hangs forever and it seems like nothing is being done.
However, if I run:
docker pull mcr.microsoft.com/windows/servercore:1903
I can pull the image from the repository.
I'm not sure what I'm doing wrong, or how to fix it. The build command doesn't seem to have a verbose option, and I need a docker container running Windows.
I'm using Docker in Windows 10 Pro and its configured to use Windows containers.
Check which directory do you execute your commands from. You shall be executing them from directory where DOCKERFILE is located and nothing else. If you execute say from root of C drive or any other location with big number of files then docker as a first step will try to zip all of them up and then send to a builder and hence delays.
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?
New to docker and I'm using Windows 7 SP1. It looks like docker is running fine in my machine as I have tried running hello-world by command docker run hello-world as instructed in the tutorial and got expected result. Now all I'm trying to do is create a docker image for a .net core console app. My app built and ran. but while building docker image by command docker build -t myapp . I get the below error
error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.30/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&c
puquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&shmsize=0&t=
duke&target=&ulimits=null: 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.
Below my Dockerfile
FROM microsoft/dotnet:1.1-runtime-nanoserver
WORKDIR /DotNetConsole
COPY /bin/Debug/netcoreapp1.1/publish/ .
ENTRYPOINT ["dotnet", "DotNetConsole.dll"]
I could get around this problem by starting the "Docker QuickStart Terminal" installed with the docker tools, and running the commands for building the docker images from there.
If I used GIT BASH instead of the Docker QuickStart Terminal to execute the commands, I would get this kind of error. So it seems that if the commands are not executed from the Docker terminal itself, these errors show up.
I have created a docker image from my windows 7 tar backup. Everything is fine and docker images shows the image.
Now, I do not know how to create a container from this image. It seems it does not know the cmd command at all.
I tried the following:
# docker run -it 8bf47055c3d3 cmd
exec: "CMD": executable file not found in $PATH
docker: Error response from daemon: Container command not found or does not exist..
s# docker run -it 8bf47055c3d3 "Windows\System32\cmd.exe"
exec: "CMD": executable file not found in $PATH
docker: Error response from daemon: Container command not found or does not exist..
Is there any way to connect?
I did not create any Dockerfile. Just took a .tgz backup of the windows C:\ drive and ran the following command in my Linux to create the image:
cat file.tgz | docker import - devops:latest
I don't understand what you hope to do with this image.
Docker, used on Windows, is used in a boot2docker (tinycore) VM, where it can run container based on Linux images. It would not know how to interpret Windows system calls.
You would need docker for Windows (Windows 10 with Hyper-V maybe, or Windows Server 2016 TP4+, as in "Running Docker Containers On Windows Server 2016 (Quick Start Guide)") to hope running such an image.