我正在尝试用conda环境构建一个码头映像,并在启动容器时启动环境,但我不知道如何。我的Dockerfile当前是:
FROM nvidia/cuda:10.2-cudnn7-runtime-ubuntu18.04
ENV PATH="/root/miniconda3/bin:${PATH}"
ARG PATH="/root/miniconda3/bin:${PATH}"
RUN apt update \
&& apt install -y htop python3-dev wget git imagemagick
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& mkdir root/.conda \
&& sh Miniconda3-latest-Linux-x86_64.sh -b \
&& rm -f Miniconda3-latest-Linux-x86_64.sh \
&& conda create -y -n .venv python=3.7
RUN /bin/bash -c "source activate .venv \
&& pip install -r requirements.txt"
# More omitted installs
CMD ["/bin/bash", "source activate .venv"]
RUN /bin/bash -c "source activate .venv"然后我建造和运行:
docker build -f Dockerfile -t adlr .
docker run -it adlr /bin/bash->启动容器时没有激活conda环境,但我希望它是.。
发布于 2022-01-12 15:15:06
您可以在启动容器时激活环境,方法是将Dockerfile的最后一行替换为:
RUN echo "source activate .venv" >> ~/.bashrchttps://stackoverflow.com/questions/70683977
复制相似问题