【问题标题】:Conda not found when trying to build Docker image尝试构建 Docker 映像时找不到 Conda
【发布时间】:2019-08-22 21:11:00
【问题描述】:

我为 Plink 和 Peddy 制作了以下 Docker 容器,但每当我尝试构建容器时,都会收到以下错误:

Executing transaction: ...working... WARNING conda.core.envs_manager:register_env(46): Unable to register environment. Path not writable or missing.
  environment location: /root/identity_check/anaconda
  registry file: /root/.conda/environments.txt
done
installation finished.
Removing intermediate container cdf60f5bf1a5
 ---> be254b7571be
Step 7/10 : RUN conda update -y conda   && conda config --add channels bioconda         && conda install -y peddy
 ---> Running in aa2e91da28b4
/bin/sh: 1: conda: not found
The command '/bin/sh -c conda update -y conda   && conda config --add channels bioconda         && conda install -y peddy' returned a non-zero code: 127

Dockerfile:

FROM ubuntu:19.04

WORKDIR /identity_check

RUN apt-get update && \
    apt-get install -y \
        python-pip \
        tabix \
        wget \
        unzip 

RUN apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/* \
    && sudo apt-get -y update \
    && sudo pip install --upgrade pip \
    && sudo pip install awscli --upgrade --user \
    && sudo pip install boto3 \
    && sudo pip install pyyaml \
    && sudo pip install sqlitedict


# Install PLINK
RUN wget http://s3.amazonaws.com/plink1-assets/plink_linux_x86_64_20190617.zip \
    && mv plink_linux_x86_64_20190617.zip /usr/local/bin/ \
    && unzip /usr/local/bin/plink_linux_x86_64_20190617.zip

# Install Peddy
RUN INSTALL_PATH=~/anaconda \
    && wget http://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh \
    && bash Miniconda2-latest* -fbp $INSTALL_PATH \
    && PATH=$INSTALL_PATH/bin:$PATH

RUN conda update -y conda \
    && conda config --add channels bioconda \
    && conda install -y peddy

ENV PATH=$PATH:/identity_check/

ADD . /identity_check

CMD bash /identity_check/identity_setup.sh 

我已尝试更改INSTALL_PATH 并查看是否有所不同,甚至启动了虚拟机来手动测试这些安装步骤,它工作正常。我不明白为什么没有找到 conda。

【问题讨论】:

标签: docker ubuntu dockerfile conda


【解决方案1】:
# Install Peddy
RUN INSTALL_PATH=~/anaconda \
    && wget http://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh \
    && bash Miniconda2-latest* -fbp $INSTALL_PATH \
    && PATH=$INSTALL_PATH/bin:$PATH

上面的最后一部分更新了一个PATH 变量,它只存在于运行命令的shell 中。该 shell 在设置 PATH 变量后立即退出,并且用于执行 RUN 命令的临时容器退出。 RUN 命令的结果是将文件系统更改收集到正在创建的 docker 映像的层中。任何环境变量更改、后台进程启动或不属于容器文件系统的任何其他内容都会丢失。

相反,您需要更新图像环境:

# Install Peddy
RUN INSTALL_PATH=~/anaconda \
    && wget http://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh \
    && bash Miniconda2-latest* -fbp $INSTALL_PATH \
ENV PATH=/root/anaconda/bin:$PATH

如果软件允许,我会避免安装在/root 主目录中,而是将其安装在/usr/local/bin 之类的地方,如果您将容器更改为以其他用户身份运行,则可以使用它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-28
    • 2019-01-24
    • 1970-01-01
    • 2015-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-04
    相关资源
    最近更新 更多