繁体   English   中英

尝试构建Docker映像时未找到Conda

[英]Conda not found when trying to build Docker image

我为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并查看是否INSTALL_PATH ,甚至尝试启动虚拟机来手动测试这些安装步骤,并且工作正常。 我不明白为什么找不到conda。

# 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中。 设置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 ,如果将容器更改为以其他用户身份运行,则可以使用它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM