dockerfile中使用miniconda

dockerfile中使用miniconda
无conda not found

RUN wget --quiet https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \
    /bin/bash ~/miniconda.sh -b -p /opt/conda && \
    rm ~/miniconda.sh && \
    /opt/conda/bin/conda clean -tipsy && \
    ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
    echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
    echo 
  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Dockerfile 执行 `source` 命令使用 conda 环境,可以按照以下步骤进行: 1. 在 Dockerfile 安装 conda,并创建一个新的 conda 环境: ``` RUN curl -sSLO https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \ && bash Miniconda3-latest-Linux-x86_64.sh -b \ && rm Miniconda3-latest-Linux-x86_64.sh \ && echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc \ && echo "conda activate myenv" >> ~/.bashrc \ && /opt/conda/bin/conda create -y --name myenv python=3.7 \ && /opt/conda/bin/conda clean -ya ``` 这里创建了一个名为 `myenv` 的 conda 环境,并将其添加到了 `.bashrc` 文件,以便后续可以使用环境。 2. 在需要使用 conda 环境的命令前,使用 `bash -c` 执行 `source activate` 命令激活 conda 环境: ``` RUN bash -c "source activate myenv && pip install -r requirements.txt" ``` 这里使用 `source activate myenv` 命令激活了 `myenv` 环境,然后执行了 `pip install` 命令。 注意,如果你使用的是 conda 4.4 以上版本,可以使用 `conda activate` 命令代替 `source activate` 命令。 完整的 Dockerfile 可以参考以下示例: ``` FROM ubuntu:18.04 # Install conda RUN apt-get update \ && apt-get install -y curl bzip2 \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* RUN curl -sSLO https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \ && bash Miniconda3-latest-Linux-x86_64.sh -b \ && rm Miniconda3-latest-Linux-x86_64.sh \ && echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc \ && echo "conda activate myenv" >> ~/.bashrc \ && /opt/conda/bin/conda create -y --name myenv python=3.7 \ && /opt/conda/bin/conda clean -ya # Copy files COPY . /app WORKDIR /app # Install dependencies RUN bash -c "source activate myenv && pip install -r requirements.txt" # Run command CMD ["bash"] ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值