docker - 尝试构建 Docker 镜像时找不到 Conda

标签 docker ubuntu dockerfile conda

我已经为 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

Docker 文件:

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。

最佳答案

# 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 的位置,如果您将容器更改为以不同的用户身份运行。

关于docker - 尝试构建 Docker 镜像时找不到 Conda,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57617100/

相关文章:

email - 查找 ubuntu postfix 邮件服务器的 smtp 用户名和密码?

linux - 如何启动 QGIS?

java - 从 tika-app 调用 ctakes 解析器时出现异常

Docker 编写针对容器的运行测试

docker - docker 容器中的多种语言

postgresql - 从另一个容器(Docker)连接到 postgresql 容器

ruby - $ GEM_HOME和$ GEM_PATH在旅客中设置错误

docker - 使用Intellij在Spring Boot中使用Gradle构建Docker镜像

RubyMine:终止超时工作线程

docker - 如何为docker中的详细信息指定注释