简体   繁体   中英

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

#ENTRYPOINT [ "python split_csv.py -i test_data.csv -o test_data.csv -r 100" ]

WORKDIR /docker_task2

ENV PORT 80

COPY split_csv.py ./docker_task2

ADD test_data.csv ./docker_task2

COPY . /docker_task2//

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

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. 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 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.

Having fixed this, you also don't need to repeat the python interpreter in your image's CMD . You can probably simplify the Dockerfile significantly:

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"]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM