Swiss Army Knife + Docker - Env set up & retrieving outputs

Oliver G The helpers that keep the community running smoothly. UKB Community team Data Analyst

I've recently stumbled across a wrinkle using the Swiss Army Knife with a docker image where I want to source an environment setup script at initialisation.

This docker run statement is organised as:
docker run -e in_prefix=<entry to -iin=> -w /tmp -v /home/dnanexus/out/out:/tmp -v /mnt/project:/mnt/project <image-name>:<version> bash -c ‘<entry to -icmd=>’
(Check the Swiss Army Knife log file to see the set up for your use case.)
This already has a bash -c, which creates a shell to run the -icmd statement. This shell has the mounted directories and saving to /tmp will upload any outputs to your project workspace.

At the end of my .dockerfile I had:
CMD [". /usr/local/setup_script.sh && /bin/bash"]
However, the /bin/bash execution here created a child shell which did not have the mounted access set up by default by the Swiss Army Knife docker run statement.

Instead, if you want to run a CMD on docker initialisation to set up an environment and restart bash then use:

CMD [". /usr/local/setup_script.sh && exec bash"]
which prompts the new bash to inherit the existing shell properties.

not 

CMD [". /usr/local/setup_script.sh && /bin/bash"]
which doesn't.

Related to

Comments

0 comments

Please sign in to leave a comment.