下载了较新的映像 - docker:来自守护进程的错误响应:OCI 运行时创建失败:container_linux.go:348:

bga*_*ial 2 docker

我想下载busybox图像并得到它,但尽管如此,我还是有以下错误:

? bgarcial [~] ? sudo docker run busybox:1.29 "hello world"
Unable to find image 'busybox:1.29' locally
1.29: Pulling from library/busybox
90e01955edcd: Already exists 
Digest: sha256:2a03a6059f21e150ae84b0973863609494aad70f0a80eaeb64bddd8d92465812
Status: Downloaded newer image for busybox:1.29
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"hello world\": executable file not found in $PATH": unknown.
ERRO[0004] error waiting for container: context canceled 

? bgarcial [~] ? sudo docker images                        
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
busybox             1.29                59788edf1f3e        2 months ago        1.15MB
hello-world         latest              4ab4c602aa5e        3 months ago        1.84kB

? bgarcial [~] ?
Run Code Online (Sandbox Code Playgroud)

使用其他图像不会发生相同的错误,例如命令sudo docker run mongo:4-xenial...

我的问题可能是当我将“hello world”作为参数传递到我的容器中时吗?

Hax*_*iel 6

当您将命令传递给 Docker 容器时,它必须可以从 Docker 容器内的 shell 执行。在这种情况下,“Hello World”被视为您尝试运行的可执行文件的名称。由于这不是有效的可执行文件名称,Docker 返回以下错误。

[root@testvm1 test]# docker run busybox "Hello World"
container_linux.go:247: starting container process caused "exec: \"Hello World\": executable file not found in $PATH"
/usr/bin/docker-current: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \"Hello World\": executable file not found in $PATH".
Run Code Online (Sandbox Code Playgroud)

请注意这一行:"exec: \"Hello World\": executable file not found in $PATH"

使用在容器内有效的命令,例如echo要使其工作:

[root@testvm1 test]# docker run busybox echo "Hello World"
Hello World
Run Code Online (Sandbox Code Playgroud)

请注意,如果您使用 shell 以交互方式运行容器,您将看到相同的行为:

[root@testvm1 test]# docker run -it busybox /bin/sh
/ # "Hello World"
/bin/sh: Hello World: not found
/ # echo "Hello World"
Hello World
Run Code Online (Sandbox Code Playgroud)