How to run .NET core app with specific launch profile in docker container?
Its very easy these days to run an .NET application in docker container, that too with the IDE support of Docker out-of-box to create the docker file.
But, this post is more towards a specific problem as the heading says in this post, how to run .NET core app with specific launch profile in docker container.
Running Launch Settings profiles locally
.NET app usually comes with 2 default profiles one with IISExpress and another one with the name of your project, which will be the default profile used while running CLI command
For the launchSettings.json
above, in order to run the profile LocalDev
, we need to just use the following command
dotnet run
.NET will automatically take the first profile as default profile by design.
But how do we run the second profiles, the
Prod
?
Well, that we can do using the dotnet run parameter as shown below
dotnet run — launch-profile Prod
Question on how to run launch settings profile in docker container
Well, now comes the interesting part, how do we do it in Docker world ?
The answer lies in the Dockerfile
We can use the ENTRYPOINT of dockerfile where the app runs and pass the profile in there as shown below
This will spawn the specific profile of application while running in the Docker container
If this article helps, please clap and leave your comments !
Thanks