1
votes

Trying to access the command line args from a dotnet core console application in docker.

This is basically just the default template with default docker compose / dockerfile template.

Tried a few different approaches.

  • Add args to ENTRYPOINT in dockerfile
  • Added args to CMD in dockerfile
  • Added args under build in the docker-compose file

Cant get it to pass it on, how is this usually handled?

Test repo: https://github.com/lasrol/DotnetCoreDockerArgs

1
What does your dockerfile look like?Pandelis
Forgot to push the docker files to the repo. The docker file is here: github.com/lasrol/DotnetCoreDockerArgs/blob/master/TestDocker/…Lasse Vabe Rolstad

1 Answers

6
votes

CMD is meant as an alternative to ENTRYPOINT, or a way to supply arguments to an entrypoint.

Rather than doing:

ENTRYPOINT ["dotnet", "TestDocker.dll", $arg1, $arg2]
CMD ["arg1", "arg2"]

Which will repeat the arguments, Try:

ENTRYPOINT ["dotnet", "TestDocker.dll", "arg1", "arg2"]

or if you want to use both, simply use CMD for all the arguments only.

ENTRYPOINT ["dotnet", "TestDocker.dll"]
CMD ["arg1", "arg2"]

https://docs.docker.com/engine/reference/builder/#cmd