[英]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.