2016-01-28 235 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