[英]OCI runtime create failed: runc create failed: unable to start container process: exec: "split_csv.py": executable file not found in $PATH: unknown
My dockerfile我的码头文件
FROM python:latest来自python:最新
#ENTRYPOINT [ "python split_csv.py -i test_data.csv -o test_data.csv -r 100" ] #ENTRYPOINT [“python split_csv.py -i test_data.csv -o test_data.csv -r 100”]
WORKDIR /docker_task2工作目录 /docker_task2
ENV PORT 80环境端口 80
COPY split_csv.py ./docker_task2复制 split_csv.py ./docker_task2
ADD test_data.csv ./docker_task2添加 test_data.csv ./docker_task2
COPY .复制 。 /docker_task2//
/docker_task2//
CMD ["python", "split_csv.py", "test_data.csv"] CMD ["python", "split_csv.py", "test_data.csv"]
My code我的代码
docker run splitter split_csv.py -i test_data.csv -o test_data.csv -r 100 docker run splitter split_csv.py -i test_data.csv -o test_data.csv -r 100
When you start the container当你启动容器
docker run splitter \
split_csv.py -i test_data.csv -o test_data.csv -r 100
it tries to look up the command split_csv.py
in the $PATH
environment variable, following the normal Unix rules.它尝试按照正常的 Unix 规则在
$PATH
环境变量中查找命令split_csv.py
。 You've copied your script into the /docker_task2
directory in the image, which is also the current directory, and you need to explicitly specify the path since the directory isn't one of the default $PATH
locations like /usr/bin
.您已将脚本复制到映像中的
/docker_task2
目录中,该目录也是当前目录,并且您需要明确指定路径,因为该目录不是像/usr/bin
这样的默认$PATH
位置之一。
docker run splitter \
./split_csv.py ...
This is also subject to the other normal Unix rules here: the script must be executable (run chmod +x split_csv.py
on your host system if it isn't, and commit that permission change to source control) and it must begin with a "shebang" line #!/usr/bin/env python3
as the very first line of the file.这也受制于此处的其他正常 Unix 规则:脚本必须是可执行的(如果不是,则在您的主机系统上运行
chmod +x split_csv.py
,并将该权限更改提交给源代码控制),并且它必须以"shebang" line #!/usr/bin/env python3
作为文件的第一行。
Having fixed this, you also don't need to repeat the python
interpreter in your image's CMD
.修复此问题后,您也无需在图像的
CMD
中重复python
解释器。 You can probably simplify the Dockerfile significantly:您可能可以显着简化 Dockerfile:
FROM python:latest
WORKDIR /docker_task2
# Install Python library dependencies first; saves time on rebuild
# COPY requirements.txt ./
# RUN pip install -r requirements.txt
# Copy the entire context directory ./ to the current directory ./
COPY ./ ./
# Set defaults to run the image
ENV PORT 80
CMD ["./split_csv.py", "-i", "test_data.csv"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.