Dockerfile
:
FROM mcr.microsoft.com/dotnet/runtime-deps:7.0.10-alpine3.18-amd64
ARG APP_DIR=/var/lib/app/
WORKDIR $APP_DIR
# etc.
ENTRYPOINT ["MyApp"] # executable file located at /var/lib/app/MyApp
When running that container:
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "MyApp": executable file not found in $PATH: unknown.
I specified WORKDIR
, so why is the executable not found?
(It works if I use ENTRYPOINT ["/var/lib/app/MyApp"]
, so it’s not a permissions issue.)
3
Answers
There are some shortcomings in the docs for the interaction between
WORKDIR
andENTRYPOINT
.After much trial and error, this is the only way that works for me:
To successfully run your example, you can either use:
or
The reason is
and therefore you are missing
$PWD
. (link to the docs)See the difference:
ENTRYPOINT ["env"]
(Exec form)ENTRYPOINT ["sh", "-c", "env"]
(Exec form)ENTRYPOINT env
(Shell form)If the PATH does not contain the current directory, then you need to explicitly request a binary in the current directory with a
./
: