How to run .NET core app with specific launch profile in docker container?

ExecuteAutomation
ExecuteAutomation
Published in
2 min readApr 12, 2022

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

launchSettings.json

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.

First profile automatically taken, note the http://localhost:5001

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

Second profile is taken, Note the http://[::]:5001

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

--

--

ExecuteAutomation
ExecuteAutomation

ExecuteAutomation Ltd is a Software testing and its related information service company founded in 2020. Info available in YouTube and Udemy as video courses .