Docker Toolbox: Error response from daemon: invalid mode: /root/docker

╄→гoц情女王★ 提交于 2019-12-04 22:50:36

问题


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


回答1:


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



回答2:


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 first defined a shared folder on VirtualBox to the machine I use.
  • Then closed that machine and docker windows, then started docker toolbox again.
  • Then run docker-machine ssh default, and just change directory to the folder you shared (with given name). Mine was "cd mydocker", then with ls you can see the files you shared with VM.
  • And in toolbox, run docker run -it -v /mydocker:/path_in_container image_name /bin/sh
  • You should see the folder and content in /path_in_container.



回答3:


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. It should work.



来源:https://stackoverflow.com/questions/50540721/docker-toolbox-error-response-from-daemon-invalid-mode-root-docker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!