5

I have a .NET app that uses Octopus to deploy to the server. In this process, Octopus updates some of the values in the Web.Config (API keys, database connection string etc). I'm moving this app into a container on the same server, and the image has been built before Octopus gets anywhere near it.

How do I update the Web.Config based on the environment in which the docker run command is being triggered?

I've found this blog post, which seems to necessitate a config transformation file.

I could also pass everything in as environment variables to the container, but then I'd have to change how the app accesses them, which I don't want to do because there are lots of other apps to be done.

Colm Prunty
  • 1,595
  • 1
  • 11
  • 29
  • What is wrong with "environment" variable path? This is common approach to modify running container for different environments – Gregory Suvalian Jun 14 '17 at 15:50
  • 1
    Just that I don't want to modify the C# in the app that's doing `ConfigurationManager.AppSettings["Whatever"]` – Colm Prunty Jun 14 '17 at 15:55
  • Don't understand what you are saying. Update question with details of what you are doing and what you are trying to avoid. – Gregory Suvalian Jun 14 '17 at 22:41
  • I have the same issue with Docker. My code contains something like `ConfigurationManage.AppSettings["SomeSetting"]`, and I cannot change the source code, so I want to alter Web.config file *after* container is deployed. – Vladimir Panchenko Apr 13 '18 at 09:39
  • 1
    @VladimirPanchenko in the end I used a powershell script that took in environment variables and updated the Web.Config – Colm Prunty Apr 13 '18 at 18:05

0 Answers0