Error while running Docker run docker: Error response from daemon

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

Error while running Docker run docker: Error response from daemon

问题

  1. 以下是将在 Docker 容器内运行 Bash 脚本并接受两个输入并在容器内生成文件的 Docker 文件:
  2. ```Dockerfile
  3. FROM ubuntu:latest
  4. WORKDIR /app
  5. COPY gencsv.sh /app/gencsv.sh
  6. RUN chmod +x /app/gencsv.sh
  7. CMD ["/bin/bash", "/app/gencsv.sh"]
  1. 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 中找不到可执行文件:未知。

  1. <details>
  2. <summary>英文:</summary>
  3. 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

  1. &gt; docker: Error response from daemon: OCI runtime create failed:
  2. &gt; container_linux.go:380: starting container process caused: exec: &quot;2&quot;:
  3. &gt; executable file not found in $PATH: unknown.
  4. </details>
  5. # 答案1
  6. **得分**: 1
  7. `exec: "2": executable file not found in $PATH: unknown.` 这个错误意味着你尝试执行"2"作为命令,但(当然)它不是有效的命令,也不在$PATH中。
  8. 按照@Tuning85的建议使用Entrypoint
  9. CMD - 你可以覆盖默认命令。Docker认为你正在尝试执行`2 8`
  10. Entrypoint - 无法被覆盖,命令行参数将作为参数传递给"app/gencsv.sh"脚本。
  11. <details>
  12. <summary>英文:</summary>
  13. `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.
  14. Use Entrypoint as @Tuning85 said.
  15. CMD - you can override the default command. Which docker thinks you are trying to do with `2 8`
  16. Entrypoint - can&#39;t be overridden and the the command line parameters are passed as arguments to &quot;app/gencsv.sh&quot; script
  17. </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:

确定