WIndows Git-bash run docker.sock - windows

Problem
OS: Windows 10
I cannot run code bellow in git bash.
Tried using it with winpty but does not help. If I run it from cmd, it has no issues, but that is not a solution because I have a lot of commands in .sh format, so I need bash functionality. I googled the problem, but solutions are only to run from cmd.
Code below is one line
docker run -v /var/run/docker.sock:/var/run/docker.sock -d --
publish=127.0.0.1:8000:80 --network net_basic gliderlabs/logspout
Results
I expect something similar to that:
docker run -v /var/run/docker.sock:/var/run/docker.sock -d --publish=127.0.0.1:8000:80 --network net_basic gliderlabs/logspout
249a69afcdb3d80e4783c439083ec1ffd30946ccec77f2b64f66a0b41afe29e7
I get that:
docker run -v /var/run/docker.sock:/var/run/docker.sock -d --publish=127.0.0.1:8000:80 --network net_basic gliderlabs/logspout
C:/Program Files/Docker/Docker/Resources/bin/docker.exe: Error response from daemon: Mount denied:
The source path "C:/Program Files/Git/var/run/docker.sock;C"
doesn't exist and is not known to Docker.
See 'C:/Program Files/Docker/Docker/Resources/bin/docker.exe run --help'.

Check the error. Your gitbash tried to be smart and appended path to your git at the begging : C:/Program Files/Git/var/run/docker.sock. It is a bug/feature discussed here. A quick workaround would be to mount docker.sock like this :
-v //var/run/docker.sock:/var/run/docker.sock
So your full command will be :
docker run -v //var/run/docker.sock:/var/run/docker.sock -d --publish=127.0.0.1:8000:80 --network net_basic gliderlabs/logspout

This smells to me like you didn't share your drive in Docker settings.
Right click on Docker icon in system tray and select Settings.
After that go to "Shared Drives" and select a drive you want to share with Docker daemon and click "Apply".
Docker for Windows is buggy sometimes and if that doesn't work from first, just restart Docker and it should work.

Related

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

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

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