简体   繁体   English

码头运行 <image> 错误:找不到要运行的python可执行文件

[英]docker run <image> Error: Can't find python executable to run

I am running a community edition of Docker (Version 18.03.1-ce-win65 (17513)) on Win10 with Linux containers option. 我正在使用Linux容器选项在Win10上运行Docker社区版(版本18.03.1-ce-win65(17513))。 I am building an image using docker locally on Windows, and pushing it to Portus, and finally accessing it to run from HPC running Linux using Putty. 我正在Windows上使用docker本地构建映像,并将其推送到Portus,最后访问它以使用Putty从运行Linux的HPC运行。 Well, it turns out that I am unable to run an instance of the created image because of the following error: 好吧,事实证明,由于以下错误,我无法运行创建的图像的实例:

python: can't open file './Turn.py': [Errno 2] No such file or directory python:无法打开文件'./Turn.py':[Errno 2]没有这样的文件或目录

This is my Dockerfile that I am using to build an image 这是我用来构建图像的Dockerfile

FROM python:3.6
LABEL version="1.0"
LABEL build_date="xxx"
LABEL description="xxx"
COPY requirements.txt /
RUN pip install -r requirements.txt
ENV PYTHONIOENCODING UTF-8
# Set the default directory where CMD will execute on HPC
WORKDIR /turn
COPY Turn.py /Turn.py
CMD ["python", "./Turn.py"]

The build process completes successfully as indicated here: 构建过程成功完成,如下所示:

Sending build context to Docker daemon   12.8kB
Step 1/13 : FROM python:3.6
 ---> 5f87764f9df0
Step 2/13 : LABEL maintainer="xxx"
 ---> Using cache
 ---> 71cd96de7015
Step 3/13 : LABEL version="1.0"
 ---> Using cache
 ---> 2fc5cdab38a9
Step 4/13 : LABEL build_date="xxx"
 ---> Using cache
 ---> ae488b87a931
Step 5/13 : LABEL description="xxx"
 ---> Using cache
 ---> cb11a0cf08a2
Step 6/13 : COPY requirements.txt /
 ---> Using cache
 ---> 5ec08f42d1f7
Step 7/13 : RUN pip install -r requirements.txt
 ---> Using cache
 ---> dfa45323647a
Step 8/13 : ENV PYTHONIOENCODING UTF-8
 ---> Using cache
 ---> 733907694a25
Step 9/13 : ENV http_proxy="http://xxx"
 ---> Using cache
 ---> 9b0ba73057ae
Step 10/13 : ENV https_proxy="https://xxx"
 ---> Using cache
 ---> e1ea75915df8
Step 11/13 : WORKDIR /turn
 ---> Using cache
 ---> a8b8ad69d82c
Step 12/13 : COPY Turn.py /Turn.py
 ---> Using cache
 ---> 9f9cb068c16b
Step 13/13 : CMD ["python", "./Turn.py"]
 ---> Using cache
 ---> a7f10949e521
Successfully built a7f10949e521
Successfully tagged turn:latest

SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. 安全警告:您正在针对非Windows Docker主机从Windows构建Docker镜像。 All files and directories added to build context will have '-rwxr-xr-x' permissions. 添加到构建上下文的所有文件和目录都具有“-rwxr-xr-x”权限。 It is recommended to double check and reset permissions for sensitive files and directories. 建议仔细检查并重置敏感文件和目录的权限。

I am trying to run this image using the following command: 我试图使用以下命令运行此图像:

f@hpclogin1:~> docker run hpcdocker.hpc.xxx.com:5000/namespace/turn:latest 

python: can't open file './Turn.py': [Errno 2] No such file or directory python:无法打开文件'./Turn.py':[Errno 2]没有这样的文件或目录

This should be a simple path issue. 这应该是一个简单的路径问题。 Notice how you call python on ./turn.py ? 请注意你如何在./turn.py上调用python? This means you will assume it is a child of the current directory, which is - depending on your entrypoint - not necessarily the root folder where you copied it to. 这意味着您将假设它是当前目录的子目录,这取决于您的入口点 - 不一定是您将其复制到的根文件夹。

Simply changing your call CMD ["python", "./Turn.py"] CMD ["python", "/Turn.py"] should resolve the issue. 只需更改您的呼叫CMD ["python", "./Turn.py"] CMD ["python", "/Turn.py"]应解决此问题。

Looks like you're copying Turn.py to the root directory instead of in to your working directory: 看起来您正在将Turn.py复制到根目录而不是复制到您的工作目录:

COPY Turn.py ./Turn.py
# Was Missing^

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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