简体   繁体   English

Docker 无法创建 conda 虚拟环境

[英]Docker can't create conda virtual environment

I'm trying to dockerize a python application, using conda for package management.我正在尝试 dockerize 一个 python 应用程序,使用 conda 进行包管理。

I generated a specfile using:我使用以下方法生成了一个规范文件:

conda list --explicit > spec-file.txt

I have the following code in my Dockerfile:我的 Dockerfile 中有以下代码:

FROM conda/miniconda3

RUN conda create -n env --file ./spec-file.txt
RUN echo "source activate env" > ~/.bashrc
ENV PATH /opt/conda/envs/env/bin:$PATH

When I run docker-compose build , it produced the following error:当我运行docker-compose build ,它产生了以下错误:

CondaFileIOError: './spec-file.txt'. [Errno 2] No such file or directory: './spec-file.txt'

The Dockerfile and the specfile are both in the same directory. Dockerfile 和 specfile 都在同一目录中。 I've tried using absolute paths and that didn't work either.我试过使用绝对路径,但也没有用。

Turns out I needed to add the line:结果我需要添加以下行:

COPY ./spec-file.txt .

Before trying to create the environment.在尝试创建环境之前。

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

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