1

I am trying to run the official bwa docker https://hub.docker.com/r/biocontainers/bwa/, and I keep getting an error:

sudo docker run -u="root" -v ~/files/:/opt/inputs/ biocontainers/bwa "index /opt/inputs/hg19.fa"
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"index /opt/inputs/hg19.fa\": stat index /opt/inputs/hg19.fa: no such file or directory": unknown.
ERRO[0000] error waiting for container: context canceled 

EDIT: Removing the double quotes from the lst string gives a different error:

sudo docker run -u="root" -v ~/files/:/opt/inputs/ biocontainers/bwa index /opt/inputs/hg19.fa
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"index\": executable file not found in $PATH": unknown.

I have found the reason behind it here:

docker: executable file not found in $PATH

This is the correct reason, but since this file was pre-build, and I want to use the official release, I cannot change the CMD synthax in Dockerfile. How can I make this work without changing the container itself?

Cindy Almighty
  • 903
  • 8
  • 20

1 Answers1

3

since this file was pre-build, and I want to use the official release, I cannot change the CMD synthax in Dockerfile

Actually you did change the setting of CMD in your run command. Everything after the image name overrides the default CMD value shipped with the image:

sudo docker run -u="root" -v ~/files/:/opt/inputs/ biocontainers/bwa "index /opt/inputs/hg19.fa"
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"index /opt/inputs/hg19.fa\": stat index /opt/inputs/hg19.fa: no such file or directory": unknown.
ERRO[0000] error waiting for container: context canceled 

In this case, you have replaced the bwa value of CMD shipped in the Dockerfile with "index /opt/inputs/hg19.fa". Note the quotes and space are included in the executable you are trying to run. It is not trying to run index with an argument /opt/inputs/hg19.fa as you may have expected. This is why you see the error message:

"exec: \"index /opt/inputs/hg19.fa\": stat index /opt/inputs/hg19.fa: no such file or directory"

To run the command index, remove the quotes:

sudo docker run -u="root" -v ~/files/:/opt/inputs/ biocontainers/bwa index /opt/inputs/hg19.fa
BMitch
  • 231,797
  • 42
  • 475
  • 450
  • I am sorry, I posted the wrong error message, as I tried multiple versions of the command. I initially tried without it, and the error is: docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"index\": executable file not found in $PATH": unknown. – Cindy Almighty Oct 15 '18 at 12:04
  • If you need a binary that is not included with the image you've selected, you'll need to pick a different image, extend image, or include the install of that binary with your running of the image. – BMitch Oct 15 '18 at 12:11
  • Got it, just add bwa. Accepted the answer. Can you tell me how to not override the command but add arguments to it? Is that even possible if the last line is: CMD ["bwa"] ? – Cindy Almighty Oct 15 '18 at 12:12
  • The value is `CMD` is always overridden, not extended. It sounds like you're looking for the behavior of `ENTRYPOINT`. https://docs.docker.com/engine/reference/builder/#understand-how-cmd-and-entrypoint-interact – BMitch Oct 15 '18 at 12:15
  • Then why specify such a CMD? Which cannot possibly do anything, apart from print help. – Cindy Almighty Oct 15 '18 at 13:58
  • @CindyAlmighty that would be a question for the creators of that image. My guess is as an example command. – BMitch Oct 15 '18 at 14:10