Home > Mobile >  How do you pass arguments to docker run entrypoint?
How do you pass arguments to docker run entrypoint?

Time:02-17

>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

CodePudding user response:

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

docker run api-tests dotnet test

An example could be the alpine/curl image, that runs curl with the arguments you pass.

docker run --rm alpine/curl -s https://www.google.com/

will fetch the front page of Google. The parameters are just -s https://www.google.com/. The image has curl as the entrypoint, so you don't need to specify that.

CodePudding user response:

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 :

docker run api-tests test

if you have ENRTYPOINT dotnet in your dockerfile. or:

docker run api-tests dotnet test

if you have CMD this-will-be-replaced in your dockerfile

  • Related