0

If I run the following from the command line.

docker run -t repo:tag ls -l

the command succeeds just fine. However, if I invoke the same from within a bash script I get the following ERROR:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"ls -l\": executable file not found in $PATH": unknown.

What about the bash script causes this error?

3
  • 3
    Without seeing the exact invocation of the script, I'd say that you're incorrectly quoting the arguments so that "ls" "-l" has become "ls -l". Commented Dec 31, 2018 at 19:48
  • 1
    Have you tried removing the -t flag when running in the bash script? Commented Dec 31, 2018 at 19:52
  • @DanFarrell yes "ls" "-l" was being treated as "ls -l". Please put this as an answer? Commented Dec 31, 2018 at 20:48

1 Answer 1

1

"exec: \"ls -l\": executable file not found in $PATH"

From the error I can tell that when you invoke docker, you somehow invoke with ls -l including space as one argument. Something like,

docker run -t repo:tag "ls -l" # wrong

or perhaps

cmd="ls -l" 
docker run -t repo:tag "$cmd" # wrong

The shell to parse the docker command must see ls and -l as separate parameters so that the argument -l is distinguished from the ls executable name.

cmd="ls -l" 
docker run -t repo:tag $cmd #works
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.