2016-01-28 58 views
2

我是Docker的新手,所以我很抱歉这样一个简单的问题。Python在码头集装箱

我正在构建一个Docker容器,它建立在基于ubuntu的图像之上:生动的图像。 当容器内执行我的剧本,我得到一个错误:

exec: "python": executable file not found in $PATH 

我该如何解决这个问题? 当我尝试在我的泊坞文件运行apt-get install python

FROM my_image # based on ubuntu:vivid 

RUN apt-get update && \ 
    apt-get install -y python3 

ENV PATH /:$PATH 

COPY file.py/

CMD ["python", "file.py", "-h"] 

我得到:

WARNING: The following packages cannot be authenticated! 
    libexpat1 libffi6 libmagic1 libmpdec2 libssl1.0.0 libpython3.4-minimal 
    mime-support libsqlite3-0 libpython3.4-stdlib python3.4-minimal 
    python3-minimal python3.4 libpython3-stdlib dh-python python3 file 
E: There are problems and -y was used without --force-yes 
The command '/bin/sh -c apt-get update && apt-get install -y python3' returned a non-zero code: 100 
make: *** [image] Error 1 

编辑:添加Dockerfile内容

+0

的apt-get安装Python或试图找到蟒蛇可执行在乌尔机添加到$ PATH ??? – minhhn2910

+0

也许你只是使用[官方的Python Docker镜像](https://hub.docker.com/_/python/)? –

+0

@ cricket_007由于我已经基于不同的图像,我不能这样做 – Ela

回答

2

你有类似的问题,一些Linux发行版: “Why am I getting authentication errors for packages from an Ubuntu repository?

在所有情况下,安装新软件包的常用命令顺序如下:

RUN apt-get update -yq && apt-get install -yqq \ 
    git \ 
    python \ 
    ... 

OP Ela报告in the comments

RUN apt-get update -y && apt-get install -y --force-yes \ 
    git \ 
    python \ 
    ... 
+0

我尝试了你的方法,然后得到'你想继续吗? [Y/n]中止。 命令'/ bin/sh -c apt-get update && \t apt-get install - \t git \t python'returned a non-zero code:1' – Ela

+0

@Ela OK,我已经编辑了相应的答案,添加了参数'-yq'和'-yqq'应该允许你处于非交互模式。 – VonC

+0

这工作,-yq更新是不必要的。而且,这也可以通过'install -y --force-yes'来实现,如果你想要包含它,你可以更新你的答案。我不知道哪种方式更可取 – Ela