为什么 Docker 说它不能执行 'bash”?
Why does Docker say it can't execute 'bash"?
我在 MacOSX 上使用 Docker(使用 Boot2Docker)。
我可以 运行 图片来自 Docker Hub。
然而,当我尝试 运行 我自己的一张图片时,像这样:
docker run -P mylocalimage
或
docker run -P mylocalimage bin/a3-write-back
或
...
我得到:
docker "env: can't execute 'bash': No such file or directory"
我猜它找不到要在容器中执行的 bash 二进制文件,但为什么呢?
基本图像是 errordeveloper/oracle-jdk
感谢您的帮助。
阿什莉。
[{
"Architecture": "amd64",
"Author": "ABC email@email.com",
"Checksum": "tarsum.dev+sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"Comment": "",
"Config": {
"AttachStderr": false,
"AttachStdin": false,
"AttachStdout": false,
"Cmd": [],
"CpuShares": 0,
"Cpuset": "",
"Domainname": "",
"Entrypoint": [
"bin/a3-write-back"
],
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/jdk1.8.0_25/bin",
"JAVA_HOME=/usr/jdk1.8.0_25"
],
"ExposedPorts": null,
"Hostname": "5bf0de3d0926",
"Image": "abd65ce243a5b015bb49f3e958103a5cc0c5f14938df4e480ded25f3ecf878e7",
"MacAddress": "",
"Memory": 0,
"MemorySwap": 0,
"NetworkDisabled": false,
"OnBuild": [],
"OpenStdin": false,
"PortSpecs": null,
"StdinOnce": false,
"Tty": false,
"User": "daemon",
"Volumes": null,
"WorkingDir": "/opt/docker"
},
"Container": "987d2279b6e42195fe8e732c0637798926db6cfaeab93fcc25a3f10dac73f111",
"ContainerConfig": {
"AttachStderr": false,
"AttachStdin": false,
"AttachStdout": false,
"Cmd": [
"/bin/sh",
"-c",
"#(nop) CMD []"
],
"CpuShares": 0,
"Cpuset": "",
"Domainname": "",
"Entrypoint": [
"bin/a3-write-back"
],
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/jdk1.8.0_25/bin",
"JAVA_HOME=/usr/jdk1.8.0_25"
],
"ExposedPorts": null,
"Hostname": "5bf0de3d0926",
"Image": "abd65ce243a5b015bb49f3e958103a5cc0c5f14938df4e480ded25f3ecf878e7",
"MacAddress": "",
"Memory": 0,
"MemorySwap": 0,
"NetworkDisabled": false,
"OnBuild": [],
"OpenStdin": false,
"PortSpecs": null,
"StdinOnce": false,
"Tty": false,
"User": "daemon",
"Volumes": null,
"WorkingDir": "/opt/docker"
},
"Created": "2015-01-13T05:25:38.467586784Z",
"DockerVersion": "1.4.1",
"Id": "ddbd5d3f52cc5fd41605c95e4525cd2f3e0808a3741b3f8d77f46f0661945f7b",
"Os": "linux",
"Parent": "abd65ce243a5b015bb49f3e958103a5cc0c5f14938df4e480ded25f3ecf878e7",
"Size": 0,
"VirtualSize": 390826666
}
]
您的图像基于 busybox,它没有 bash shell。它在 /bin/sh
处确实有一个 shell。
所以这行不通:
$ docker run -it busybox bash
exec: "bash": executable file not found in $PATH2015/01/15 11:09:08 Error response from daemon:
Cannot start container a5074af2f81f8cc1eb0076f4ec9ada5f87be1440006f54a9b06ab701fc60176a: exec:
"bash": executable file not found in $PATH
但是这样做:
$ docker run -it busybox /bin/sh
/ #
由于您的入口点脚本,可能会有更多的复杂性,但您始终可以覆盖它。
如果您的图像具有定义的 ENTRYPOINT,这将不起作用。对于这些情况,请使用:
'
docker 运行 -it --入口点 /bin/bash
'
如果您的图像定义了 ENTRYPOINT,如何用 bash 覆盖 docker 运行:
docker run -it --entrypoint /bin/bash <your-image>
我在 MacOSX 上使用 Docker(使用 Boot2Docker)。
我可以 运行 图片来自 Docker Hub。
然而,当我尝试 运行 我自己的一张图片时,像这样:
docker run -P mylocalimage
或
docker run -P mylocalimage bin/a3-write-back
或
...
我得到:
docker "env: can't execute 'bash': No such file or directory"
我猜它找不到要在容器中执行的 bash 二进制文件,但为什么呢?
基本图像是 errordeveloper/oracle-jdk
感谢您的帮助。
阿什莉。
[{
"Architecture": "amd64",
"Author": "ABC email@email.com",
"Checksum": "tarsum.dev+sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"Comment": "",
"Config": {
"AttachStderr": false,
"AttachStdin": false,
"AttachStdout": false,
"Cmd": [],
"CpuShares": 0,
"Cpuset": "",
"Domainname": "",
"Entrypoint": [
"bin/a3-write-back"
],
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/jdk1.8.0_25/bin",
"JAVA_HOME=/usr/jdk1.8.0_25"
],
"ExposedPorts": null,
"Hostname": "5bf0de3d0926",
"Image": "abd65ce243a5b015bb49f3e958103a5cc0c5f14938df4e480ded25f3ecf878e7",
"MacAddress": "",
"Memory": 0,
"MemorySwap": 0,
"NetworkDisabled": false,
"OnBuild": [],
"OpenStdin": false,
"PortSpecs": null,
"StdinOnce": false,
"Tty": false,
"User": "daemon",
"Volumes": null,
"WorkingDir": "/opt/docker"
},
"Container": "987d2279b6e42195fe8e732c0637798926db6cfaeab93fcc25a3f10dac73f111",
"ContainerConfig": {
"AttachStderr": false,
"AttachStdin": false,
"AttachStdout": false,
"Cmd": [
"/bin/sh",
"-c",
"#(nop) CMD []"
],
"CpuShares": 0,
"Cpuset": "",
"Domainname": "",
"Entrypoint": [
"bin/a3-write-back"
],
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/jdk1.8.0_25/bin",
"JAVA_HOME=/usr/jdk1.8.0_25"
],
"ExposedPorts": null,
"Hostname": "5bf0de3d0926",
"Image": "abd65ce243a5b015bb49f3e958103a5cc0c5f14938df4e480ded25f3ecf878e7",
"MacAddress": "",
"Memory": 0,
"MemorySwap": 0,
"NetworkDisabled": false,
"OnBuild": [],
"OpenStdin": false,
"PortSpecs": null,
"StdinOnce": false,
"Tty": false,
"User": "daemon",
"Volumes": null,
"WorkingDir": "/opt/docker"
},
"Created": "2015-01-13T05:25:38.467586784Z",
"DockerVersion": "1.4.1",
"Id": "ddbd5d3f52cc5fd41605c95e4525cd2f3e0808a3741b3f8d77f46f0661945f7b",
"Os": "linux",
"Parent": "abd65ce243a5b015bb49f3e958103a5cc0c5f14938df4e480ded25f3ecf878e7",
"Size": 0,
"VirtualSize": 390826666
}
]
您的图像基于 busybox,它没有 bash shell。它在 /bin/sh
处确实有一个 shell。
所以这行不通:
$ docker run -it busybox bash
exec: "bash": executable file not found in $PATH2015/01/15 11:09:08 Error response from daemon:
Cannot start container a5074af2f81f8cc1eb0076f4ec9ada5f87be1440006f54a9b06ab701fc60176a: exec:
"bash": executable file not found in $PATH
但是这样做:
$ docker run -it busybox /bin/sh
/ #
由于您的入口点脚本,可能会有更多的复杂性,但您始终可以覆盖它。
如果您的图像具有定义的 ENTRYPOINT,这将不起作用。对于这些情况,请使用: ' docker 运行 -it --入口点 /bin/bash '
如果您的图像定义了 ENTRYPOINT,如何用 bash 覆盖 docker 运行:
docker run -it --entrypoint /bin/bash <your-image>