Error while running Docker run docker: Error response from daemon

huangapple go评论80阅读模式
英文:

Error while running Docker run docker: Error response from daemon

问题

以下是将在 Docker 容器内运行 Bash 脚本并接受两个输入并在容器内生成文件的 Docker 文件:

```Dockerfile
FROM ubuntu:latest

WORKDIR /app

COPY gencsv.sh /app/gencsv.sh

RUN chmod +x /app/gencsv.sh

CMD ["/bin/bash", "/app/gencsv.sh"]
docker run -dp 9393:9393 -v "$(pwd)/inputFile:/app/inputFile" input 2 8

docker: 容器创建失败的错误响应:OCI runtime create failed: container_linux.go:380: 启动容器进程引发了错误:exec: "2": 在 $PATH 中找不到可执行文件:未知。


<details>
<summary>英文:</summary>

Below is the Docker file which will run bash script inside docker container and takes two input and generates file inside container

FROM ubuntu:latest

WORKDIR /app

COPY gencsv.sh /app/gencsv.sh

RUN chmod +x /app/gencsv.sh

CMD ["/bin/bash", "/app/gencsv.sh"]`

docker run -dp 9393:9393 -v "$(pwd)/inputFile:/app/inputFile" input 2 8

&gt; docker: Error response from daemon: OCI runtime create failed:
&gt; container_linux.go:380: starting container process caused: exec: &quot;2&quot;:
&gt; executable file not found in $PATH: unknown.


</details>


# 答案1
**得分**: 1

`exec: "2": executable file not found in $PATH: unknown.` 这个错误意味着你尝试执行"2"作为命令,但(当然)它不是有效的命令,也不在$PATH中。

按照@Tuning85的建议使用Entrypoint。

CMD - 你可以覆盖默认命令。Docker认为你正在尝试执行`2 8`

Entrypoint - 无法被覆盖,命令行参数将作为参数传递给"app/gencsv.sh"脚本。

<details>
<summary>英文:</summary>

`exec: &quot;2&quot;: executable file not found in $PATH: unknown.` This error means you&#39;re trying to execute &quot;2&quot; as a command, but (of course) it&#39;s not valid and not in $PATH.

Use Entrypoint as @Tuning85 said.

CMD - you can override the default command. Which docker thinks you are trying to do with `2 8`
Entrypoint - can&#39;t be overridden and the the command line parameters are passed as arguments to &quot;app/gencsv.sh&quot; script

</details>



huangapple
  • 本文由 发表于 2023年8月5日 16:21:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76840737.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定