1

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

Lasse Vabe Rolstad
  • 602
  • 2
  • 9
  • 20

1 Answers1

6

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

Oofpez
  • 514
  • 1
  • 7
  • 18
Pandelis
  • 1,854
  • 13
  • 20
  • Tried that also, not working. As statet in the orginal description i have tried the to add them to entrypoint, added as args with CMD and also added to args in the compose file. – Lasse Vabe Rolstad Jan 12 '18 at 14:54
  • Works for me. See also https://stackoverflow.com/questions/40272341/how-to-pass-parameters-to-a-net-core-project-with-dockerfile/40280368#comment89116050_40280368. – Volker von Einem Jun 27 '18 at 13:13