我想下载 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 [~] →
使用其他图像不会发生相同的错误,例如命令sudo docker run mongo:4-xenial
...
我的问题是否可能是当我将“hello world”作为参数传递到我的容器中时执行?
答案1
当您将命令传递到 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".
请注意这一行:"exec: \"Hello World\": executable file not found in $PATH"
。
使用容器内有效的命令,例如echo
要使其工作:
[root@testvm1 test]# docker run busybox echo "Hello World"
Hello World
请注意,如果使用 shell 以交互方式运行容器,您将看到相同的行为:
[root@testvm1 test]# docker run -it busybox /bin/sh
/ # "Hello World"
/bin/sh: Hello World: not found
/ # echo "Hello World"
Hello World