>docker run --entrypoint "dotnet test" api-tests
This says it can’t find the executable in the path variable.
>docker run --entrypoint "dotnet" api-tests
This works but doesn’t do anything.
How do you pass multiple arguments?
e.g. dotnet test UnitTests.csproj --logger trx;LogFileName=/tests/test-results.trx
3
Answers
Whatever is after the image name replaces any defined CMD and is sent as parameter to the entrypoint.
So if you have an entrypoint defined, that you want to pass ‘dotnet test’ to, you’d do
An example could be the alpine/curl image, that runs curl with the arguments you pass.
will fetch the front page of Google. The parameters are just
-s https://www.google.com/
. The image hascurl
as the entrypoint, so you don’t need to specify that.Just add them all the way in the end.
For
ENTRYPOINT
it adds to whatever was specified in the dockerfile.In case
CMD
was used it will replace it.so use :
if you have
ENRTYPOINT dotnet
in your dockerfile.or:
if you have
CMD this-will-be-replaced
in your dockerfileIf you need the
docker run --entrypoint
command, only the first shell word (the actual container-side binary to run) goes there. The remaining arguments have to go after the image name, as the "command" arguments in thedocker run
command syntax.However, you can design your image to avoid needing this. If the image uses
CMD
to declare its primary command and notENTRYPOINT
, then you can similarly provide the override command in the "command" part of thedocker run
command.I tend to reserve
ENTRYPOINT
for a wrapper script that ends inexec "$@"
, so it still runs theCMD
, or for aFROM scratch
image where it’s literally impossible to run anything other than the single binary in the image.