Docker Community Forums

Share and learn in the Docker community.

Docker container conda - source

I am trying to create a docker image that has a conda environment with PyTorch, but I get an error message source: not found.

Dockerfile

FROM continuumio/miniconda3

FROM anibali/pytorch:1.8.1-cuda11.1-ubuntu20.04

USER user

COPY --chown=user ./environment.yaml /home/user/app/environment.yaml

RUN conda init bash &&  source /home/user/.bashrc && conda activate my_env

WORKDIR /home/user/app

but I get this error message:

Step 5/6 : RUN conda init bash &&  source /home/user/.bashrc && conda activate my_env
 ---> [Warning] Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
 ---> Running in f435bbf4b511
no change     /home/user/miniconda/condabin/conda
no change     /home/user/miniconda/bin/conda
no change     /home/user/miniconda/bin/conda-env
no change     /home/user/miniconda/bin/activate
no change     /home/user/miniconda/bin/deactivate
no change     /home/user/miniconda/etc/profile.d/conda.sh
no change     /home/user/miniconda/etc/fish/conf.d/conda.fish
no change     /home/user/miniconda/shell/condabin/Conda.psm1
no change     /home/user/miniconda/shell/condabin/conda-hook.ps1
no change     /home/user/miniconda/lib/python3.8/site-packages/xontrib/conda.xsh
no change     /home/user/miniconda/etc/profile.d/conda.csh
modified      /home/user/.bashrc

==> For changes to take effect, close and re-open your current shell. <==

/bin/sh: 1: source: not found
The command '/bin/sh -c conda init bash &&  source /home/user/.bashrc && conda activate my_env' returned a non-zero code: 127

How can I solve this? I know how to use pip. but I need conda to have best reproducibility with one cluster that doesn’t run docker.