Docker Windows – 在bash位置寻找Ubuntu命令

docker工人。 已下载DockerToolbox-1.10.2.exe并安装在Windows 7上,似乎正在正常运行。

在以下地方试用hello world教程:

Docker.com上的Hello World

当我运行以下命令

$ docker run ubuntu /bin/echo 'Hello world' 

它似乎下载Ubuntu镜像:

 Unable to find image 'ubuntu:latest' locally latest: Pulling from library/ubuntu 5a132a7e7af1: Pull complete fd2731e4c50c: Pull complete 28a2f68d1120: Pull complete a3ed95caeb02: Pull complete Digest: sha256:4e85ebe01d056b43955250bbac22bdb8734271122e3c78d21e55ee235fc6802d Status: Downloaded newer image for ubuntu:latest 

但后来我得到了以下错误信息:

 exec: "C:/devel/Git/bin/echo": stat C:/devel/Git/bin/echo: no such file or directory docker: Error response from daemon: Container command not found or does not exist 

那个path就是我在Windows上运行bash.exe来运行docker的地方。 我相信这肯定是一个configuration问题,但我不知道该从哪里出发。

你可能有一个PATH,其中有c:\devel\Git ,其余的之前,使外壳调用错误的回声。
尝试更改该顺序( set PATH=...;c:\devel\Git )。

确保先连接到你的机器:

 docker-machine ssh 

然后,您可以再次尝试您的码头运行命令

简答

使用/跳出命令中的unix样式路径。 以下的作品。

 $ docker run ubuntu //bin/echo 'Hello world' Hello world 

更长的答案

这种行为背后原因似乎是Git Bash(基于MinGW64 / MSYS2 )试图在找到unix风格的路径时进行一些智能路径转换 。 我只找到转换的源代码(我相信这里 ),但没有文档。 我发现的唯一文档是MSYS1路径转换 ,它应该是相似的。

让我引用MSYS1路径转换的截图。 从示例中可以看到,像/bar这样的“unix-style”路径将被重写为MSYS2根目录的相对路径(即Git Bash情况下的Git目录),而像//foobar这样的转义路径按原样通过。

MSYS1路径转换实例截图

尝试docker run ubuntu //bin/echo 'Hello world'