Issue running project using docker - windows

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

Related

The command to create a file in docker via make does not work

Docker Toolbox is installed on a Windows 8.1 PC. When I enter the command in the PhpStorm terminal, it works successfully and the file is created:
docker run --rm -v //D_DRIVE/work/7_project-manager/manager:/app --workdir=/app alpine touch .ready
If I put the same command in the Makefile and run make manager-ready
manager-ready:
docker run --rm -v //D_DRIVE/work/7_project-manager/manager:/app --workdir=/app alpine touch .ready
it works out with an error (other make commands work fine, the problem is only with this command):
D:\work\7_project-manager>make manager-ready
docker run --rm -v //D_DRIVE/work/7_project-manager/manager:/app --workdir=/app alpine touch .ready
C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: the working directory 'C:/msys64/app' is invalid, it needs to be an absolute path.
See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.
make: *** [Makefile:43: manager-ready] Error 125
How to solve the problem?

Why have I an error message "invalid reference format" when working with Docker?

I'm following the below tutorial and they use docker. I got an error When I tried to mount my local folder to the container.
https://www.youtube.com/watch?v=bhBSlnQcq2k
docker run --name some-nginx -v $(pwd):/usr/share/nginx/html:ro -d -p 8080:80 nginx
I got the following error:
docker: invalid reference format.
I am using Windows 10 PowerShell, Visual Studio Code, and Nginx image. Any ideas are highly appreciated.
with powershell you should use ${PWD} instead of $(pwd)
then you should do
docker run --name some-nginx -v ${PWD}:/usr/share/nginx/html:ro -d -p 8080:80 nginx
possible duplicate of : Mount current directory as a volume in Docker on Windows 10

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

'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