Boot2docker / Windows:无法在Ubuntu容器上运行bash

时间:2022-02-12 20:55:13

I'm working through "The Docker Book", am on chapter 3, installing and running an Ubuntu container. I'm on Windows 7.1, using Boot2Docker.

我正在通过“Docker Book”,我在第3章,安装和运行Ubuntu容器。我在Windows 7.1上,使用Boot2Docker。

Here's what happens when I try to run it (this is the second attempt, so it already has a local copy of the image):

以下是我尝试运行时发生的情况(这是第二次尝试,因此它已经有了图像的本地副本):

$ docker run -i -t 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 5e985b0b101bb9584ea3e40355089a54d1fba29655d5a1e0900c9b32c4f7e4c4: [8] System error: exec: "C:/Program Files (x86)/Git/bin/bash": stat C:/Program Files (x86)/Git/bin/bash: no such file or directory

Status:

$ docker ps -a
CONTAINER ID    IMAGE           COMMAND                CREATED            STATUS              PORTS   NAMES
5e985b0b101b    ubuntu:latest   "C:/Program Files (x   21 minutes ago     loving_mayer

It's complaining about lack of C:/Program Files (x86)/Git/bin/bash, but I certainly have that on my machine:

它抱怨缺少C:/ Program Files(x86)/ Git / bin / bash,但我当然在我的机器上有这个:

$ ls -l "c:/Program Files (x86)/Git/bin/bash"
-rwxr-xr-x    1 neilw    Administ   598016 May  4 09:27 c:/Program Files (x86)/Git/bin/bash

Any thoughts?

3 个解决方案

#1


This works for me:

这对我有用:

docker run -t -i ubuntu //bin/bash

The double // avoids the conversion[1]

双// //避免转换[1]

[1] http://www.mingw.org/wiki/Posix_path_conversion

#2


I've just had the same problem, but

我刚遇到同样的问题,但是

docker run -t -i ubuntu

opens up a shell inside the image.

在图像中打开一个shell。

#3


It looks like your host's shell is automatically expanding /bin/bash to C:/Program Files (x86)/Git/bin/bash before it is passed to Docker, which isn't correct as obviously there isn't a C:/Program Files (x86)/Git/bin/bash inside the Ubuntu container.

看起来你的主机的shell在传递给Docker之前自动扩展/ bin / bash到C:/ Program Files(x86)/ Git / bin / bash,这是不正确的,因为很明显没有C:/ Ubuntu容器中的Program Files(x86)/ Git / bin / bash。

Does using quotes fix the problem? For example:

使用引号可以解决问题吗?例如:

docker run -i -t ubuntu "/bin/bash"

#1


This works for me:

这对我有用:

docker run -t -i ubuntu //bin/bash

The double // avoids the conversion[1]

双// //避免转换[1]

[1] http://www.mingw.org/wiki/Posix_path_conversion

#2


I've just had the same problem, but

我刚遇到同样的问题,但是

docker run -t -i ubuntu

opens up a shell inside the image.

在图像中打开一个shell。

#3


It looks like your host's shell is automatically expanding /bin/bash to C:/Program Files (x86)/Git/bin/bash before it is passed to Docker, which isn't correct as obviously there isn't a C:/Program Files (x86)/Git/bin/bash inside the Ubuntu container.

看起来你的主机的shell在传递给Docker之前自动扩展/ bin / bash到C:/ Program Files(x86)/ Git / bin / bash,这是不正确的,因为很明显没有C:/ Ubuntu容器中的Program Files(x86)/ Git / bin / bash。

Does using quotes fix the problem? For example:

使用引号可以解决问题吗?例如:

docker run -i -t ubuntu "/bin/bash"