[英]Docker 'run' not finding file
我正在嘗試從 Docker 容器運行 Python 文件,但收到錯誤:
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.
我使用命令構建和運行:
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"]
安裝.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
我嘗試將 Dockerfile 中的 CMD 修改為:
CMD ["/models/PriceNotifications.py"]
但同樣的錯誤發生。
文件結構如下:
我應該如何修改 Dockerfile 或 dir 結構,以便找到並執行models/PriceNotifications.py
?
感謝之前的評論,使用路徑:
CMD ["/models/models/PriceNotifications.py"]
代替
CMD ["./models/PriceNotifications.py"]
允許 Python 腳本運行。
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 Docker 運行的一部分。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.