如何调试 nvidia-docker build 中丢失的路径

How to debug missing path in nvidia-docker build

我正在创建一个 nvidia-docker 镜像,Dockerfile 中包含以下内容:

RUN curl -so /miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh  && chmod +x /miniconda.sh  && /miniconda.sh -b -p /miniconda  && rm /miniconda.sh
ENV PATH=/miniconda/bin:$PATH
#this is stored in cache ---> fa383a2e1344
# check path
RUN /miniconda/bin/conda

我收到以下错误:

/bin/sh: 1: /miniconda/bin/conda: not found
The command '/bin/sh -c /miniconda/bin/conda' returned a non-zero code: 127

当我测试路径时使用:

nvidia-docker run --rm fa383a2e1344 ls

然后 /miniconda 不存在因此错误。

然后我更改了 Dockerfile 以将 /miniconda 替换为环境变量路径,即:

ENV CONDA_DIR $HOME/miniconda
# Install Miniconda
RUN curl -so /miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \
 && chmod +x /miniconda.sh \
 && /miniconda.sh -b -p CONDA_DIR \
 && rm /miniconda.sh

ENV PATH=$CONDA_DIR:$PATH

# check path
RUN $CONDA_DIR/conda

并得到错误:

/bin/sh: 1: /miniconda/conda: not found
The command '/bin/sh -c $CONDA_DIR/conda' returned a non-zero code: 127

我能够通过设置当前目录的路径而不是点击 /

来让它工作
   WORKDIR /miniconda
   RUN curl -so ./miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \
    && chmod +x ./miniconda.sh \
    && ./miniconda.sh -b -p CONDA_DIR

这里是构建结果供参考

  docker build - < Dockerfile 
  Sending build context to Docker daemon  3.072kB
  Step 1/5 : FROM node:12.16.0-alpine
   ---> 466593119d17
  Step 2/5 : RUN apk update && apk add --no-cache curl
   ---> Using cache
   ---> 1d6830c38dfa
  Step 3/5 : WORKDIR /miniconda
   ---> Using cache
   ---> 8ee9890a7109
  Step 4/5 : WORKDIR /miniconda
   ---> Running in 63238c179aea
  Removing intermediate container 63238c179aea
   ---> 52f571393bf6
  Step 5/5 : RUN curl -so ./miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh       && chmod +x ./miniconda.sh       && ./miniconda.sh -b -p CONDA_DIR
   ---> Running in b59e945ad7a9
  Removing intermediate container b59e945ad7a9
   ---> 74ce06c9af66
  Successfully built 74ce06c9af66