I am a Docker newbie and currently replicating course videos. I have to add that I only have Windows 10 Home and I am hence limited to Docker Toolbox. (At work I have W 10 Pro and use Docker itself and didnt experience the problem I am about to report).
When I run the following in the Windows Power Shell:
PS C:\Program Files\Docker Toolbox> docker run -ti -h python -v ${pwd}:/root/docker -p 9999:9999 ubuntu:latest /bin/bash
I get the following error
C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: invalid mode: /root/docker.
See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.
The problem doesnt occur in the command prompt, so it seems to be related to the Power Shell. I did not find anything in discussion boards. Any input would be appreciated.
Best Markus
I got the same issue while using docker toolbox. Using one more '/' before your source path as well as before your target path will resolve this problem. In your case it will look like this:
docker run -ti -h python -v /${pwd}://root/docker -p 9999:9999 ubuntu:latest /bin/bash
if this doesn't work then try using absolute path with extra '/' like this:
docker run -ti -h python -v //c/path_to_application://root/docker -p 9999:9999 ubuntu:latest /bin/bash
The "invalid mode" error comes from parsing the third field in a volume mount, where each field is separated by a colon. In this command:
docker run -ti -h python -v ${pwd}:/root/docker -p 9999:9999 ubuntu:latest /bin/bash
The ${pwd}
is going to expand to something like c:\Program Files\...
. That means the volume mount will get parsed as:
C
(or your current drive letter, this gets processed as a named volume rather than a host path)/Program Files/...
or wherever you happen to be running this command from./root/
which is an "invalid mode" (normal options include things like ro
for a read only mount)What's needed is a leading slash before the drive letter, and you want to remove the extra colon after the drive letter. With PowerShell, you may be forced to expand the path manually without using ${pwd}
. That would look like:
docker run -ti -h python -v "/c/Program Files/...:/root/docker" -p 9999:9999 ubuntu:latest /bin/bash
If you use git bash, it has its own unique feature of turning something with a forward slash into a relative path under its install directory. To disable that, you switch to a second leading slash:
docker run -ti -h python -v "/$(pwd):/root/docker" -p 9999:9999 ubuntu:latest //bin/bash
Note in both examples, I've quoted the path in case in includes spaces.
Turned out that Docker Toolbox needs a different approach as stated in this discussion
Docker Forums: Map Windows Directory to Docker Container
As they said,
On Windows, you can not directly map Windows directory to your container. Because your containers are reside inside a VirtualBox VM. So your docker -v command actually maps the directory between the VM and the container.
So you have to do it in two steps:
Map a Windows directory to the VM through VirtualBox manager Map a directory in your container to the directory in your VM You better use the Kitematic UI to help you. It is much eaiser.
I suggest you to use absolute path in windows, Something like:
docker run -ti -h python -v /c/path_to_application:/root/docker -p 9999:9999 ubuntu:latest /bin/bash
Add /c/then_remaining_part_to_your_app
, note that /c/
is the drive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With