horcle_buzz
horcle_buzz

Reputation: 2161

How to start docker containers from a bash script?

I have not been able to find any satisfactory answer to this. I have a simple script in which I wish to run several containers in daemon mode:

#!/usr/bin/env bash

docker run -d -it -v /mnt/DataResearch/DataStageData/ed_provider_notes/:/data -v /home/gsilver1/data/QuickUMLS/data/:/data/UMLS ahc-nlpie-docker.artifactory.umn.edu/qumls:1 /home/QuickUMLS/run.sh

docker run -d -it -v /mnt/DataResearch/DataStageData/ed_provider_notes/:/data ahc-nlpie-docker.artifactory.umn.edu/b9:1 /usr/share/biomedicus/scripts/run_biomedicus.sh

docker run --env  umlsUser='USER' --env umlsPass='PW' -d -it -v /mnt/DataResearch/DataStageData/ed_provider_notes/:/data ahc-nlpie-docker.artifactory.umn.edu/clmp:4 /usr/share/clamp/scripts/run_clamp.sh

docker run -d -it -v /mnt/DataResearch/gsilver1/note_test/ed_provider_notes/:/data ahc-nlpie-docker.artifactory.umn.edu/mm:4 /usr/share/public_mm/scripts/run_metamap.sh

docker run --env  ctakes_umlsuser='USER' --env ctakes_umlspw='PW' -d -it -v /mnt/DataResearch/DataStageData/ed_provider_notes/:/data ahc-nlpie-docker.artifactory.umn.edu/ctks:1 /usr/share/ctakes/scripts/run_ctakes.sh

These commands run fine when executed from the terminal. However, when run from a script, I get errors along the lines of:

(base) gsilver1@d0pconcourse002:~/development/scripts$ ./run_nlp.sh
./run_nlp.sh: line 3: docker run -d -v /mnt/DataResearch/DataStageData/ed_provider_notes/:/data -v /home/gsilver1/data/QuickUMLS/data/:/data/UMLS ahc-nlpie-docker.artifactory.umn.edu/qumls:1 /home/QuickUMLS/run.sh: No such file or directory
./run_nlp.sh: line 5: docker run -d -v /mnt/DataResearch/DataStageData/ed_provider_notes/:/data ahc-nlpie-docker.artifactory.umn.edu/b9:1 /usr/share/biomedicus/scripts/run_biomedicus.sh: No such file or directory
./run_nlp.sh: line 7: docker run --env  umlsUser='horcle' --env umlsPass='nEj123456' -d -v /mnt/DataResearch/DataStageData/ed_provider_notes/:/data ahc-nlpie-docker.artifactory.umn.edu/clmp:4 /usr/share/clamp/scripts/run_clamp.sh: No such file or directory
./run_nlp.sh: line 9: docker run -d -v /mnt/DataResearch/DataStageData/ed_provider_notes/:/data ahc-nlpie-docker.artifactory.umn.edu/mm:4 /usr/share/public_mm/scripts/run_metamap.sh: No such file or directory
./run_nlp.sh: line 11: docker run --env  ctakes_umlsuser='horcle' --env ctakes_umlspw='nEj123456' -d -v /mnt/DataResearch/DataStageData/ed_provider_notes/:/data ahc-nlpie-docker.artifactory.umn.edu/ctks:1 /usr/share/ctakes/scripts/run_ctakes.sh: No such file or directory
(base) gsilver1@d0pconcourse002:~/development/scripts$

Which, seems to indicate that the script is not interpreting the commands at the end of the docker command to run within the docker container's filesystem, not from the remote filesystem. I've tried putting quotes around the docker command and then using a -c to run as a specific user, etc. all to no avail. How do I get the commands to run within each docker's container, without having to modify the entrypoint of the docker image?

Upvotes: 1

Views: 666

Answers (1)

Arnaud Claudel
Arnaud Claudel

Reputation: 3138

Try to wrap your paths with quotes, sometimes it causes unexpected behaviour.

Upvotes: 2

Related Questions