I try to create a new anaconda environment inside docker. I get an error message I cannot get rid of. What I do in my Dockerfile is:
FROM postgis/postgis:12-master
ENV BAG_ENV=bag
RUN wget https://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh --quiet -O /tmp/anaconda.sh
RUN /bin/bash /tmp/anaconda.sh -b -p /opt/conda
RUN conda update conda
RUN conda init bash
RUN . /opt/conda/etc/profile.d/conda.sh
RUN conda create --name $BAG_ENV --force -y python=3.8.2 pip conda libxml2 lxml gdal psycopg2
RUN conda activate $BAG_ENV
I have the same error when running similar instructions from a bash script. The error I get is:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
From this link I learned to source conda.sh
. This works for my bash script but not in my Dockerfile. How can I solve this problem?
I run this from an Ubuntu 20.04 machine, the Dockerfile is derived from alpine.