How to mount a windows folder in docker container? - docker

On my windows notebook I try to share a folder with my docker container, but I am getting a weird error message that does not tell me anything.
docker run -p 9999:9999 -it msmint/msmint:latest -v c:/Users/swacker/MINT:/data/
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "-v": executable file not found in $PATH: unknown.
The /data folder in the docker file is present and I gried different formats for the windows path such as C:\User\swacker\MINT.
It complains that an executable file is not found, but I don't know which one.

Options for docker need to go before the image name. Anything after the image name is a command for the container and replaces any defined CMD in the image.
So you need to do
docker run -p 9999:9999 -it -v c:\Users\swacker\MINT:/data/ msmint/msmint:latest
I've changed the slashes in your Windows path to backslashes.

Related

`$PATH: unknown` error when mounting the current directory in Docker

I want to use Docker to manage multiple Python versions (I recently got a Mac with Apple Silicon and I use old Python environment).
Since I need to read Python scripts on Docker and save the output files (for later use outside the Docker environment), I tried to mount a folder (on my Mac) following this post.
However, it shows this error:
$ docker run --name dpython -it python-docker -v $(pwd):/tmp /bin/bash
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "-v": executable file not found in $PATH: unknown.
ERRO[0000] error waiting for container: context canceled
It works without -v $(pwd):/tmp. I tried to specify different folders such as ~/ and /Users/ but they didn't work.
You must specify the volume before the image name:
$ docker run --name dpython -it -v $(pwd):/tmp python-docker /bin/bash

Cannot mount a folder with Docker

I can't get the -v option to work with Docker. My host is Linux Mint and my image is using Ubuntu:latest.
sudo docker run -it opencv:latest -v /home/rr/Desktop/mytest:/src
It gives the error
docker: Error response from daemon: OCI runtime create failed:
container_linux.go.345: starting container process caused
"exec: \"-v\": executable file not found in $PATH": unknown.
I have tried different things. Both mounting to a folder in the image that exists and one that does not, but it is the same error either way.
The usage of docker run is:
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
So your options need to go before the image name, including the -v option. If you put it after the image name, it sees it as the command to run instead of an option. Try:
sudo docker run -it -v /home/rr/Desktop/mytest:/src opencv:latest

Cannot run FreeBSD terminal in docker container

I am using a FreeBSD image from dockerhub. After pulling the image, I need to run a container with a terminal to test some commands inside the container.
I am trying this command:
sudo docker run --rm -it auchida/freebsd ./bin/bash
And I get the error:
docker: Error response from daemon: OCI runtime create failed:
container_linux.go:348: starting container process caused "exec:
\"./bin/bash\": stat ./bin/bash: no such file or directory": unknown
Could anyone help me ?
There is no bash binary embedded in the image, located at /bin/bash or everywhere else : you can check it by looking at base.txz contents.
You can use /bin/sh instead (the default shell, take a look at the Dockerfile) :
sudo docker run --rm -it auchida/freebsd /bin/sh
(/bin/sh is optional in the previous command, since it is the default CMD).
If you really want bash, you must install it.
Note also that you must be on a FreeBSD host to be able to run a container with this image.

Docker --mount throws: executable file not found in $PATH"

Running:
docker run 6740371b6542 --mount
docker run 6740371b6542 --mount source=aws,target=/root/.aws/,readonly
both produce the same error:
container_linux.go:265: starting container process caused "exec: \"--mount\": executable file not found in $PATH"
docker: Error response from daemon: oci runtime error: container_linux.go:265: starting container process caused "exec: \"--mount\": executable file not found in $PATH".
Can someone explain how to mount a file/folder from the host into the docker container? It seems --mount is the current/latest recommended way to do it.
switching the order of the parameters should resolve that problem
docker run --mount source=aws,target=/root/.aws/,readonly 6740371b6542
docker run executes a command as its last parameter. the error you received was due to the container not knowing what the --mount command is
In the future if you want to run a command in a container dont forget to use bash if you want to preserve path variables
docker run --mount source=aws,target=/root/.aws/,readonly 6740371b6542 /bin/bash -c mysql

Boot2Docker starting Ubuntu image

I am trying to get the latest Ubuntu image going om my Windows 7/Boot2Docker machine but when i try to start the image i get an error message.
exec: "C:/Program Files (x86)/Git/bin/bash": stat C:/Program Files (x86)/Git/bin/bash: no such file or directory
Full errormessage:
$ docker run -t -i ubuntu /bin/bash
exec: "C:/Program Files (x86)/Git/bin/bash": stat C:/Program Files (x86)/Git/bin/bash: no such file or directory
FATA[0000] Error response from daemon: Cannot start container 100e77a5ac95f8fb8dc55e6382e7a8cd6f946ec807e90d9efdb6fc905a046569: [8] System error: exec: "C:/Program Files (x86)/Git/bin/bash": stat C:/P
rogram Files (x86)/Git/bin/bash: no such file or directory
Any clue on how to work around this? Another image like the default Jenkins one works ok!
The Ubuntu image is pulled correctly
Running Ubuntu image after SSH:
docker#boot2docker:~$ docker run ubuntu
docker#boot2docker:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS
It means that somehow your $PATH (within the boot2docker session) includes "C:/Program Files (x86)/Git/bin/" before /bin.
Check the $PATH you have when running docker run --rm -it ubuntu:latest.
The fact that you manage to run the image in a boot2docker ssh session, but docker ps displays nothing seems expected.
Only a docker run --rm -it ubuntu would display a shell.
A simplt docker run would exit the shell immadiatly (non-interactive run), and the container would be in status 'Exited' (see docker ps -a output)
First of all, before you create a container, you have to run "Boot2Docker Start" to start docker virtual machine then start your container inside docker VM. follow up the instructions in this link https://docs.docker.com/installation/windows/
Second, I think that it is preferred to install docker over linux machine not windows, you will get all capabilities of docker.
Best Regards,
Ahmed

Resources