1

As a novice to the technology I have only a basic knowledge regarding how to build and deploy a docker so i was hoping someone could provide some help.

The situation is the following:

I need to create a docker container with two conda environments and then I want to call a command line from my native os (linux).

Firs i created two conda envs:

env-a.yml:

conda create --name env-a
conda activate env-a
conda install -c bioconda samtools
conda env export > env-a.yml

env-b.yml:

conda create --name env-b
conda activate env-b
conda install -c bioconda samtools
conda env export > env-b.yml

Next I build my docker container

Dockerfile:

    FROM continuumio/miniconda3
     COPY ./env-a.yml /opt/
     COPY ./env-b.yml /opt/
     RUN conda env create -f /opt/env-a.yml
     RUN conda env create -f /opt/env-b.yml
     RUN echo "source activate env-a" > ~/.bashrc
     ENV PATH /opt/conda/envs/env/bin:$PATH

my build :

docker build -t test ./

and now i run it

docker run -it test
(env-a) root@1c44fcc2e83d:/#

looks good… now i want to mount a location from which my files are read and execute two pipelines each calling tools from different environment:

docker run --init -v /media/data/home/booby/test/:/opt/ test /bin/bash -c "source activate env-a && env view -h /opt/my.bam > /opt/my.sam && source activate env-b && samtools view -b /opt/my.sam > /opt/my.bam"

but when i mount a volume (-v) , it seams I lose access to my conda envs.

/bin/bash: activate: No such file or directory

what would be the proper way to set this up?

Thank you

1 Answer 1

0

You're overwriting the contents of /opt/ in the container with the contents from /media/data/home/booby/test/. Mount it in some other directory - for example to a subdirectory of /opt as shown below as shown below

docker run --init -v /media/data/home/booby/test/:/opt/sam /bin/bash -c "source activate env-a && env view -h /opt/sam/my.bam > /opt/sam/my.sam && source activate env-b && samtools view -b /opt/sam/my.sam > /opt/sam/my.bam"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.