# Calling commands on docker file

**URL:** <https://community.seqera.io/t/calling-commands-on-docker-file/928>\
**Category:** Ask for help\
**Created:** [July 5, 2024, 10:46pm UTC](https://community.seqera.io/t/calling-commands-on-docker-file/928 "2024-07-05T22:46:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bskubi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/bskubi/32/545_2.png) [@bskubi](https://community.seqera.io/u/bskubi)\
**Post date:** [July 5, 2024, 10:46pm UTC](https://community.seqera.io/t/calling-commands-on-docker-file/928/1 "2024-07-05T22:46:48Z")

</div>

I am trying to use a dockerized version of a python library called [Mustache](https://github.com/ay-lab/mustache).

This library contains a Python file called diff\_mustache.py. Within the running docker session, the absolute path to a desired file is /mustache/mustache/diff\_mustache.py. When running this dockerfile on my local machine, it’s necessary to call `source ~/.bashrc` on the dockerfile to activate the environment in which diff\_mustache.py has access to its required dependencies. Then I can run diff\_mustache.py. The command I use to call diff\_mustache manually outside of Nextflow is:

docker run -it bskubi/mustache /bin/bash -c “source ~/.bashrc && python mustache/mustache/diff\_mustache.py”

This displays the help menu for diff\_mustache. Is there a way to do something equivalent from within Nextflow?

---

<div class="post-metadata">

**Author:** ![mribeirodantas](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/mribeirodantas/32/235_2.png) [@mribeirodantas](https://community.seqera.io/u/mribeirodantas)\
**Post date:** [July 6, 2024, 5:33am UTC](https://community.seqera.io/t/calling-commands-on-docker-file/928/2 "2024-07-06T05:33:01Z")

</div>

Did you try using the `containerOptions` process directive? Something like:

```auto
process FOO {
  container 'busybox:latest'
  containerOptions '-c "source ~/.bashrc && python mustache/mustache/diff_mustache.py"'

  ...
}

```

You can read more about it [here](https://www.nextflow.io/docs/latest/process.html#containeroptions).

---

<div class="post-metadata">

**Author:** ![Adam\_Talbot](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/adam_talbot/32/62_2.png) [@Adam\_Talbot](https://community.seqera.io/u/Adam_Talbot)\
**Post date:** [July 8, 2024, 1:17pm UTC](https://community.seqera.io/t/calling-commands-on-docker-file/928/3 "2024-07-08T13:17:03Z")

</div>

I don’t think containerOptions would work here for sourcing the file, but you could use it to set an environment variable such as `PATH` to help you? There is also [`docker.runOptions`](https://www.nextflow.io/docs/latest/config.html#scope-docker) for a Docker specific set or args.

But the easiest option is to fix the container so it’s ready to use out of the box.

---

<div class="post-metadata">

**Author:** ![mribeirodantas](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/mribeirodantas/32/235_2.png) [@mribeirodantas](https://community.seqera.io/u/mribeirodantas)\
**Post date:** [July 8, 2024, 2:08pm UTC](https://community.seqera.io/t/calling-commands-on-docker-file/928/4 "2024-07-08T14:08:30Z")

</div>

Not sure if you meant this, but the issue with `runOptions` (for clarity to other readers here) is that it applies to all processes, and as this question is related to a tool, I’d assume it’s specific to one or some but not all processes of the pipeline. I agree that the best solution is to fix the container image.

Sourcing files like that is always tricky, as this file is not necessarily on the same place depending on the compute environment. Fixing the container image should be the way to go.

---

<div class="post-metadata">

**Author:** ![bskubi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/bskubi/32/545_2.png) [@bskubi](https://community.seqera.io/u/bskubi)\
**Post date:** [July 23, 2024, 11:59pm UTC](https://community.seqera.io/t/calling-commands-on-docker-file/928/5 "2024-07-23T23:59:37Z")

</div>

I wound up fixing the container image to eliminate this problem. Thank you!
