Dockerfile构建突然失败

Dockerfile build fails all of a sudden

当 运行 命令低于 dockerfile 构建时,我正在尝试解决构建问题, 例如我得到的错误:
1.

/bin/sh: 1: /opt/conda/bin/pip: not found
The command '/bin/sh -c wget -q https://repo.continuum.io/miniconda/Miniconda3-4.2.12-Linux-x86_64.sh -O /tmp/miniconda.sh  &&     echo 'd0c7c71cc5659e54ab51f2005a8d96f3 */tmp/miniconda.sh' | md5sum -c - &&     bash /tmp/miniconda.sh -f -b -p /opt/conda &&     /opt/conda/bin/conda install --yes -c conda-forge       python=3.5 sqlalchemy tornado jinja2 traitlets requests pip pycurl       nodejs configurable-http-proxy &&     /opt/conda/bin/pip install --upgrade pip &&     rm /tmp/miniconda.sh' returned a non-zero code: 127

2。 当试图评论有问题的部分时,我们遇到了 npm 的另一个问题,例如: /bin/sh: 1: npm: not found

知道这里发生了什么吗?

Dockerfile

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

FROM debian:jessie
MAINTAINER Jupyter Project <jupyter@googlegroups.com>

# install nodejs, utf8 locale, set CDN because default httpredir is unreliable
ENV DEBIAN_FRONTEND noninteractive
RUN REPO=http://cdn-fastly.deb.debian.org && \
    echo "deb $REPO/debian jessie main\ndeb $REPO/debian-security jessie/updates main" > /etc/apt/sources.list && \
    apt-get -y update && \
    apt-get -y upgrade && \
    apt-get -y install wget locales git bzip2 &&\
    /usr/sbin/update-locale LANG=C.UTF-8 && \
    locale-gen C.UTF-8 && \
    apt-get remove -y locales && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*
ENV LANG C.UTF-8

# install Python + NodeJS with conda
RUN wget -q https://repo.continuum.io/miniconda/Miniconda3-4.2.12-Linux-x86_64.sh -O /tmp/miniconda.sh  && \
    echo 'd0c7c71cc5659e54ab51f2005a8d96f3 */tmp/miniconda.sh' | md5sum -c - && \
    bash /tmp/miniconda.sh -f -b -p /opt/conda && \
    /opt/conda/bin/conda install --yes -c conda-forge \
      python=3.5 sqlalchemy tornado jinja2 traitlets requests pip pycurl \
      nodejs configurable-http-proxy && \
    /opt/conda/bin/pip install --upgrade pip && \
    rm /tmp/miniconda.sh
ENV PATH=/opt/conda/bin:$PATH

EXPOSE 8000

RUN mkdir -p /src/jupyterhub
WORKDIR /src/jupyterhub

ADD . /src/jupyterhub


RUN npm install --unsafe-perm && \
    pip install . && \
    rm -rf $PWD ~/.cache ~/.npm

ADD . /src/jupyterhub        
LABEL org.jupyter.service="jupyterhub"

CMD ["jupyterhub"]

由 conda forge 托管的最新 pip 包是 noarch/pip-20.0.2-py_2.tar.bz2,它缺少 bin 文件夹,因此调用 /opt/conda/bin/pip 会出现 /opt/conda/bin/pip: not found 错误。

我建议强制执行包的版本以防止更新版本导致构建错误,这将在不同的机器上实现确定性构建,从而节省时间,不必弄清楚是什么版本更改导致了错误。

为了正确获得 pip,用下面的方法修改 Dockerfile 应该可以解决问题:

RUN wget -q https://repo.continuum.io/miniconda/Miniconda3-4.2.12-Linux-x86_64.sh -O /tmp/miniconda.sh  && \
    echo 'd0c7c71cc5659e54ab51f2005a8d96f3 */tmp/miniconda.sh' | md5sum -c - && \
    bash /tmp/miniconda.sh -f -b -p /opt/conda && \
    /opt/conda/bin/conda install --yes -c conda-forge \
      python=3.5 sqlalchemy tornado jinja2 traitlets requests pip=18.0=py35_1001 pycurl \
      nodejs configurable-http-proxy && \
    /opt/conda/bin/pip install --upgrade pip && \
    rm /tmp/miniconda.sh