starting container process caused "exec: > \"exec\": executable file not found in $PATH": unknown
Asked Answered
S

3

9

I have this Dockerfile:

FROM 939fj39f3932.dkr.ecr.us-west-2.amazonaws.com/teros_keys:8e31674

WORKDIR /zoom

COPY app.sh .

ENTRYPOINT ["exec", "/zoom/app.sh"]
CMD []

I build it and it works fine. Then I run it with:

docker run --rm -d \
    -e "db_prefix=$db_prefix" \
    --name "$n" "$full_name"

and I get this error:

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

anyone know what's up with that?

Sumikosumma answered 8/8, 2019 at 23:22 Comment(0)
S
6

I changed it to:

ENTRYPOINT ["bash", "/zoom/app.sh"]

and it worked, dunno why tho

Sumikosumma answered 8/8, 2019 at 23:24 Comment(1)
As stated in David's answer, exec is a built-in of the shell, not a standalone command. Also, a best practice to follow would be invoking /bin/bash, using the absolute path, that one does not need to rely on the PATH defined in the container.Rathbone
I
6

When you use the JSON-array form of ENTRYPOINT (or CMD or RUN), the command is run exactly as-is. There is no shell handling at all. exec, though, is what the standard refers to as a "special built-in utility"; it only exists within the context of a shell. Docker winds up looking for a /bin/exec or /usr/bin/exec tool, and it's not there, yielding that error message.

If you can just run the script as is (it's executable and has a correct "shebang" line #!/bin/sh or similar) then you don't need a modifier like exec. You can just specify it directly

# No ENTRYPOINT
CMD ["/zoom/app.sh"]
Inapt answered 9/8, 2019 at 1:13 Comment(0)
R
0

In my case, the issue is I tried to use like this CMD ["ls -a"].

resolution: changed to CMD ["ls", "-a"]

Ribaldry answered 25/2, 2021 at 20:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.