Skip to main content
With your ASP.NET Core application image (kodekloudapp:v1) built, you can now run and customize it without rebuilding. This guide shows how to:
  • Launch the container in detached mode
  • Map host ports to container ports
  • Edit appsettings.json at runtime
  • Override settings using environment variables

1. Run the Container

Use docker run to start your app in detached mode, mapping port 8080 on your host to port 80 in the container and naming it for easy management:
Verify it’s running:
Your application should now be live at
http://localhost:8080
Containers are ephemeral. Any file changes made inside will be lost if the container is removed.

2. Edit Configuration In-Place

ASP.NET Core reads appsettings.json at startup via IConfiguration. You can exec into the running container, modify the JSON file, and immediately see the changes—no image rebuild required.
  1. Open a shell inside the container:
  2. Install vim (the base image is minimal):
  3. Edit the settings file:
  4. In vim, update the "Message" property:
  5. Save and exit. Reload http://localhost:8080 in your browser to see the new message.
The image shows a web page titled "KodeKloudApp" with a welcome message and a highlighted text saying "Message: Hello World from VIM !!!". The page includes links to "Home" and "Privacy".
Editing configuration inside a running container is ideal for demos and debugging—but not for production. Prefer mounting configuration files or injecting environment variables instead.

3. Override with Environment Variables

ASP.NET Core’s configuration provider loads environment variables after JSON, allowing overrides without editing files.
  1. Stop and remove the current container:
  2. Launch a new container with the Message environment variable:
  3. Refresh http://localhost:8080. The message should read From Env.

4. Cleanup

When you’re done, remove the container:

Docker Command Reference

Watch Video