Conda inside docker

389 views
Skip to first unread message

Mateusz Kuc

unread,
Feb 2, 2022, 1:32:12 PM2/2/22
to Nextflow
Hello,

I have a problem with using conda in nextflow's docker, because it doesn't recognize conda enviroment. Is it possible to use conda in nextflow's docker? I want to use it this way due to multiple troubles installing correct version of R package in docker.

Best regards,
Mateusz Kuc

sylvain...@gmail.com

unread,
Feb 3, 2022, 2:15:10 AM2/3/22
to Nextflow
Hi,

In one of my pipeline, I do use conda inside a docker. 

I run the conda command from outside the conda environemnment with the command

conda run -n condaenvironment cmds

Hereafter an excerpt of my process :

process articAnalysis {
   
    input:
        blabla
   
    output:
        blabla

       
    when:
        blabla
       
    script:
       
        """
            conda run -n condaenv condacommand1

            conda run -n condaenv condacommand2

        """  
       
}


Hope I could help,

Sylvain

Mateusz Kuc

unread,
Feb 4, 2022, 8:58:10 AM2/4/22
to Nextflow
Thank for your answer. 
I still have issue with this. When i try activate conda I have error message thath i I have to init bash first and then I do that it also doesn't work.
Best regards,
Mateusz Kuc

sylvain...@gmail.com

unread,
Feb 4, 2022, 9:50:54 AM2/4/22
to Nextflow
Hi Mateusz,

I am far from being a conda specialist ... in fact, I generally avoid using it... From what I understood when I built my pipeline. If you don't want to activate conda (which is the main problem in our case as the docker container becomes interactive after activation), you have to run your command directly with

conda run -n condaenv condacommand1

At least, with me, it's working...

Alan Hoyle

unread,
Feb 4, 2022, 10:34:47 AM2/4/22
to next...@googlegroups.com
My experience is that you can also add the conda/bin directory to your $PATH within your processes, or use the /full/path/to/bin/command_to_run in there.  The latter limits your .nf to only running in a container context which can be annoying/limiting to portability/generality.  

If you want to try the $PATH route, try adding something like the following line near the end of your Dockerfile:
ENV PATH="/opt/conda/bin:/opt/condabin:${PATH}"
If you build multiple or named conda environments, you might need to add something like /opt/conda/envs/$MY_CONDA_ENV/bin 

You can also do this on a per-process basis using variables in profiles in your nextflow.config 

-alan

--
  -  Alan Hoyle  -  al...@alanhoyle.com  -  http://www.alanhoyle.com/  -


--
You received this message because you are subscribed to the Google Groups "Nextflow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nextflow+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nextflow/46476776-fe84-46ae-a3f7-4942c10a0d67n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages