简体   繁体   中英

Docker 'run' not finding file

I'm attempting to run a Python file from a Docker container but receive the error:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"./models/PriceNotifications.py\": stat ./models/PriceNotifications.py: no such file or directory": unknown.

I build and run using commands:

docker build -t pythonstuff .

docker tag pythonstuff adr/test

docker run -t adr/test

Dockerfile:

FROM ubuntu:16.04

COPY . /models

# add the bash script
ADD install.sh /
# change rights for the script
RUN chmod u+x /install.sh
# run the bash script
RUN /install.sh
# prepend the new path
ENV PATH /root/miniconda3/bin:$PATH

CMD ["./models/PriceNotifications.py"]

install.sh:

apt-get update  # updates the package index cache
apt-get upgrade -y  # updates packages
# installs system tools
apt-get install -y bzip2 gcc git  # system tools
apt-get install -y htop screen vim wget  # system tools
apt-get upgrade -y bash  # upgrades bash if necessary
apt-get clean  # cleans up the package index cache

# INSTALL MINICONDA
# downloads Miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O Miniconda.sh
bash Miniconda.sh -b  # installs it
rm -rf Miniconda.sh  # removes the installer
export PATH="/root/miniconda3/bin:$PATH"  # prepends the new path

# INSTALL PYTHON LIBRARIES
conda install -y pandas  # installs pandas
conda install -y ipython  # installs IPython shell

# CUSTOMIZATION
cd /root/
wget http://hilpisch.com/.vimrc  # Vim configuration

I've tried modifying the CMD within the Dockerfile to:

CMD ["/models/PriceNotifications.py"]

but the same error occurs.

The file structure is as follows:

在此处输入图像描述

How should I modify the Dockerfile or dir structure so that models/PriceNotifications.py is found and executed?

Thanks to earlier comments, using the path:

CMD ["/models/models/PriceNotifications.py"]

instead of

CMD ["./models/PriceNotifications.py"]

Allows the Python script to run.

I would have thought CMD ["python /models/models/PriceNotifications.py"] should be used instead of CMD ["/models/models/PriceNotifications.py"] to invoke the Python interpreter but the interpreter seems to be already available as part of the Docker run.

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