I've got a .NET Core project (using visual studio and adding the docker files via the Visual Studio Tools for Docker).
My DockerFile
looks like this:
FROM microsoft/dotnet:1.0.1-core
ARG source=.
WORKDIR /app
COPY $source .
ENTRYPOINT ["dotnet", "MyApp.dll"]
CMD ["arg1", "arg2"]
My question is, how do I pass parameters into the project?
public static void Main(string[] args)
{
// how does `args` get populated?
}
You can do this with a combination of ENTRYPOINT
to set the command, and CMD
to set default options.
Example, for an ASP.NET Core app:
ENTRYPOINT ["dotnet", "app.dll"]
CMD ["argument"]
If you run the container with no command, it will execute this command when the container starts:
dotnet app.dll argument
And the args
array will have one entry, "argument". But you can pass a command o docker run
to override the CMD
definition:
docker run app arg1 arg2