docker run--入口点“;python/path/to/file.py“;原因“;没有这样的文件或目录:未知。”;错误
在容器shell中运行docker run--入口点“;python/path/to/file.py“;原因“;没有这样的文件或目录:未知。”;错误,docker,Docker,在容器shell中运行docker run-it--entrypoint“bash”fnb backend,然后运行python/app/main/src/api/frontend/customer\u api/customer\u api.py 考虑下面的Dockerfile: FROM python:2.7.18-slim COPY main/requirements.txt . RUN cat requirements.txt | xargs -n 1 pip install --no-c
docker run-it--entrypoint“bash”fnb backend
,然后运行python/app/main/src/api/frontend/customer\u api/customer\u api.py
考虑下面的Dockerfile:
FROM python:2.7.18-slim
COPY main/requirements.txt .
RUN cat requirements.txt | xargs -n 1 pip install --no-cache-dir; exit 0
ENV PYTHONUNBUFFERED True
COPY . ./app/
RUN mkdir -p /app/main/logs/flask/ && touch /app/main/logs/flask/webhook_api.log
# below works
#ENTRYPOINT python /app/main/src/api/frontend/customer_api/customer_api.py
注释掉的行也可以正常工作
但是运行docker run--entrypoint“python/app/main/src/api/frontend/customer\u api/customer\u api.py”fnb backend
原因:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:367: starting container process caused: exec: "python /app/main/src/api/frontend/customer_api/customer_api.py": stat python /app/main/src/api/frontend/customer_api/customer_api.py: no such file or directory: unknown.
ERRO[0000] error waiting for container: context canceled
- Dockerfile中使用的是
入口点的shell形式,请参见:
- 您在docker run中使用的
可以覆盖--entrypoint
中Dockerfile
的命令,这意味着它只能充当entrypoint
,而不是命令
的语法,请参阅:命令参数1
--entrypoint
,docker会将其视为一个完整的命令,因此如果使用命令param1 param2
,它会尝试查找命令param1 param2
的可执行文件,结果将是文件未找到
对于您来说,正确的方法是下一步将params
放入docker run
命令:
docker run --entrypoint python fnb-backend /app/main/src/api/frontend/customer_api/customer_api.py
(如果在本地运行entrypoint命令,包括双引号,会发生什么?为什么?)