为什么我需要一个shell脚本来在容器内运行python脚本?

时间:2018-11-23 14:06:48

标签: python docker

为什么第一个Dockerfile不起作用?意味着它报告了docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"python3 hello.py\": executable file not found in $PATH": unknown. ERRO[0001] error waiting for container: context canceled,第二个Dockerfile在哪里像一个吊饰一样工作?

换句话说,为什么我需要一个shell脚本来在容器内运行python脚本?

Dockerfile 1:

FROM python:3.7-alpine
COPY hello.py .
ENTRYPOINT [ "python hello.py" ]

Dockerfile 2:

FROM python:3.7-alpine
COPY hello.py .
COPY entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT [ "entrypoint.sh" ]

1 个答案:

答案 0 :(得分:1)

ENTRYPOINT语法要求

  • ENTRYPOINT [ "python", "hello.py" ]执行表单,推荐

  • ENTRYPOINT python hello.py外壳形式