I am trying to create a docker container with some conda environments. When I run the container in interactive mode running
conda update --all
conda env create -f env.yml
runs with no issues. However whenever I try to execute these commands with a Docker file I recieve
/bin/sh: 1: conda: command not foud
Docker file is shown below:
FROM ubuntu:latest
RUN apt-get update && \
apt-get install unzip && \
mkdir /install && \
apt-get install nano
COPY Anaconda3-2018.12-Linux-x86_64.sh env.yml /install/
WORKDIR /install
RUN bash Anaconda3-2018.12-Linux-x86_64.sh -b && \
echo "export PATH="/root/anaconda3/bin:$PATH"" >> ~/.bashrc && \
/bin/bash -c "source ~/.bashrc"
RUN conda update --all
RUN conda env create -f env.yml
So it appears that sh is being used instead of bash so I edited the Dockerfile to the following:
FROM ubuntu:latest
RUN apt-get update && \
apt-get install unzip && \
mkdir /install && \
apt-get install nano
COPY Anaconda3-2018.12-Linux-x86_64.sh env.yml /install/
WORKDIR /install
RUN bash Anaconda3-2018.12-Linux-x86_64.sh -b && \
echo "export PATH="/root/anaconda3/bin:$PATH"" >> ~/.bashrc && \
/bin/bash -c "source ~/.bashrc"
RUN /bin/bash -c "conda update --all"
with the following error
/bin/bash: conda: command not found
You have to add anaconda to the PATH during build time with the
ENV
variable before executing anaconda inside the Dockerfile.Updating PATH in .bashrc will make it possible to call conda inside the container, when run with
docker run
, but not in otherRUN
statements in the docker file.