在`docker build`期间使用`pip`安装python模块失败

我正在尝试构建一个 Docker 容器,我想在其中安装一些 Python 模块pip(最终将需要这些模块来构建应用程序)。我写了以下内容Dockerfile:


FROM ubuntu:16.04


RUN echo "===> Adding prerequisites..."   && \

    apt update -y            && \

    DEBIAN_FRONTEND=noninteractive  \

        apt install --no-install-recommends -y -q  \

                build-essential                        \

                python python-pip python-dev           && \

    pip install --upgrade setuptools pip wheel      && \

    pip install --upgrade pyyaml


# Default command

CMD [ "echo", "Hello!" ]

构建 ( docker build -t app:0 .)时,我得到以下输出:


Sending build context to Docker daemon  10.26MB

Step 1/3 : FROM ubuntu:16.04

 ---> 4a689991aa24

Step 2/3 : RUN echo "===> Adding prerequisites..."   &&     apt update -y            &&     DEBIAN_FRONTEND=noninteractive          apt install --no-install-recommends -y -q                  build-essential                                        python python-pip python-dev           &&     pip install --upgrade setuptools pip wheel      &&     pip install --upgrade pyyaml

 ---> Running in 9d813b5bc68d

===> Adding prerequisites...


WARNING: apt does not have a stable CLI interface. Use with caution in scripts.


Get:1 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]

[More apt output, no errors here]

Get:18 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [8532 B]

Fetched 15.5 MB in 1s (11.3 MB/s)

Reading package lists...

Building dependency tree...

Reading state information...

All packages are up to date.


WARNING: apt does not have a stable CLI interface. Use with caution in scripts.


但是,如果我pip从 Dockerfile 中删除第二个调用,则容器似乎已成功构建。


任何人都可以帮我理解是什么触发了构建错误?提前谢谢了!


繁华开满天机
浏览 610回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python