Use nerdctl to bind mount volume on Windows - containerd

I am trying to use nerdctl run command and bind mount a volume for a Windows container (nanoserver version 1809). Below are the containerd and nerdctl versions and the commands that I have tried, with the console output:
PS C:\> containerd -v
containerd github.com/containerd/containerd v1.6.8 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
PS C:\> nerdctl -v
nerdctl version 0.23.0
PS C:\> nerdctl run -it --rm -v "C:\:C:\Host" nano:1809 cmd.exe
time="2022-09-23T17:16:47-07:00" level=fatal msg="failed to parse \"C:\\\\:C:\\\\Host\""
PS C:\> nerdctl run -it --rm -v "/:/Host/" nano:1809 cmd.exe
time="2022-09-23T17:16:53-07:00" level=warning msg="expected an absolute path, got a relative path \"/\" (allowed for nerdctl, but disallowed for Docker, so unrecommended)"
time="2022-09-23T17:16:53-07:00" level=fatal msg="expected an absolute path, got \"/Host/\""
Can anyone kindly let me know how I can start a container using containerd as runtime? Should I try to use ctr or crictl for bind mounting volumes in Windows for Windows containers? Kindly point me to a solution.

Related

Issue running project using docker

I am trying to install docker in my windows machine and run the project with given command.
docker run -it -p 8000:80 --rm -v "$PWD":/var/www/html registry.XXXXXX/docker-images/legacy-admin:master
I am running windows so instead of $PWD, I used D:/projects/
But I am getting the following error
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: invalid reference format.
See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'
docker run -it -d -p 8000:80 --rm -v "$PWD":/var/www/html registry.XXXXXX/docker-images/legacy-admin:maste
Try running above lines

how to mount windows directory to a windows container

I am trying to mount a windows directory inside a windows docker container that runs with image microsoft/aspnetcore-build:2.0
I tried below commands
docker run -it microsoft/aspnetcore-build:2.0 -v dotnetcore:c:\dotnet
docker run -it microsoft/aspnetcore-build:2.0 -v dotnetcore:c:
docker run -it microsoft/aspnetcore-build:2.0 -v dotnetcore:c:\\
docker run -it microsoft/aspnetcore-build:2.0 -v dotnetcore
docker run -d microsoft/aspnetcore-build:2.0 -v dotnetcore:c:\\dotnet
All the above commands threw the error
docker: Error response from daemon: container 66e8c16cdf607c9e7ecb049963c602d22c9850f331e3d08c3acc557db4d40814 encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: {"CommandLine":"-v dotnetcore:c:\\dotnet","WorkingDirectory":"C:\\","Environment":{"ASPNETCORE_PKG_VERSION":"2.0.8","ASPNETCORE_URLS":"http://+:80","DOTNET_RUNNING_IN_CONTAINER":"true","DOTNET_SDK_DOWNLOAD_SHA":"5cae6f4c577182e7d84d991b9d20162c1a76ce17f65b7b52a7e6df8d98ec389e03626f61969eaed4f23a5f6c96a3ab188e71a0b94cc58f86e485ac9296c4af64","DOTNET_SDK_DOWNLOAD_URL":"https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.1.200/dotnet-sdk-2.1.200-win-x64.zip","DOTNET_SDK_VERSION":"2.1.200","DOTNET_USE_POLLING_FILE_WATCHER":"true","NODE_DOWNLOAD_SHA":"3d3d72c5c93a50d5a19f65f0de196b5237792a99b89fac2b61e62da4f566c842","NODE_VERSION":"6.13.0","NUGET_XMLDOC_MODE":"skip","RestoreUseSkipNonexistentTargets":"false"},"EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[30,131]}.
Any help to resolve this will be highly appreciated
You need to put -v parameter before image name

docker sharing host directory

I used to share my host diretory with a docker container with the command (osx):
docker run --name tensorflower -it -p 8888:8888 -v /c/foo/labs:/home tensorflow/tensorflow
on windows it used to work with:
docker run --name tensorflower -it -p 8888:8888 -v //c/foo/labs:/home tensorflow/tensorflow
But now it does not work on windows. I tried both -v variants. As I do not get any error messages, I have no glue where to dig in to solve the problem.
How can I share the host directory c:\foo\labs with my docker container?
Or at least get some more informaton regarding the error?
Docker version 17.09.1-ce, build 19e2cf6 on windows 10

Run a docker image on Windows results in "oci runtime error: exec: "bash": executable file not found in $PATH."

I'm running Docker on Windows ("Docker Toolbox", not "Docker for Windows").
I've built an image with a rails app inside. It works properly on my Mac OS but stucks on production on Windows.
Using Docker 1.12 and docker-machine 0.8.0 on both machines.
When I create a machine and try to run the container from image, I do:
docker run -it myRepo:myTag bash
which opens me a interactive terminal on Mac OS, but Windows 7 and Windows Server 2011 are both responding with:
"Error response from daemon: oci runtime error: exec: "bash":
executable file not found in $PATH."
I use the MINGW64 shell via the Docker Quickstart Terminal but the old cmd.exe returns the same.
Can anybody help me with this issue? I've tried several hours to find a solution but there are too few answers for Windows.
Thank you in advance!
I also use Windows 7 with MINGW64. Here is what I get using nginx as example:
$docker run -it nginx bash
cannot enable tty mode on non tty input
I don't think you can open a tty using MINGW64.
You can try:
$docker run -i nginx bash
ls
bin
...
You will so no prompt or any indication you are inside the container. Just run ls and it should work inside your container.
Another option is to try to use winpty for the tty:
$ winpty docker run -it myRepo:myTag bash
root#644f59e6f818:/#
Have you tried?
$ winpty docker run -it myRepo:myTag /bin/bash
I haven't got the problem you are mentioning but I have seen it before when I was mapping volumes.
If you are mapping volumes using MINGW64, you will need to add an extra / before the local mapping. For example:
docker run -p 8080:80 -v "/$PWD":/var/share/nginx/html nginx
Let me know your findings.

'docker run -v' does not work on Windows using Docker Toolbox

When running the following command from a CoreOS VM, it works as expected:
docker run --rm -v $PWD:/data composer init
It will initialize the composer.json file in the current working directory by using the Docker volume mapping as specified. The Docker container basically has the PHP tool composer installed and will run that tool inside the /data folder of the container. By using the mapping it actually applies it on the files on the host machine.
However when trying to run this command on Windows using Docker Toolbox I get the following error.
$ docker run --rm -v $PWD:/data composer --help
invalid value "C:\\Users\\Marco;C:\\Program Files\\Git\\data" for flag -v: bad mount mode specified : \Program Files\Git\data
See 'C:\ProgramData\Chocolatey\lib\docker\bin\docker.exe run --help'.
What I notice here is although I am in Git Bash when executing the command it still uses Windows paths. So then I tried following (surround with quotes):
$ "docker run --rm -v $PWD:/data composer --help"
bash: docker run --rm -v /c/Users/Marco:/data composer --help: No such file or directory
Now it is unable to find the directory.
I also tried without the $PWD variable, but this doesn't make a difference.
How do I make this work on Windows?
This should work:
$ docker run --rm -v //c/Users/Marco:/data composer --help
Try MSYS_NO_PATHCONV=1 docker run ...
Git Bash tries to convert the path for other Windows commands.

Resources