dotnet-docker icon indicating copy to clipboard operation
dotnet-docker copied to clipboard

Example of using multiple Docker containers with HTTPS and HOSTNAME

Open LKujala opened this issue 1 year ago • 5 comments

use multiple Docker containers with HTTPS and HOSTNAME for development

instead of using localhost instances for developing and debugging applications, would like to use Docker containers which are closer to what a production environment would look like. examples samples/run-aspnetcore-https-development.md show how to configure a single Docker container. The problem is with a multi-container solution (eg application using a micro-service architecture) I have yet to find an example that actually works.

Describe the Solution

Example showing

  • 3 containers: service1, service 2, service3.
  • each container has a defined hostname: service1.local, service2.local, service3.local
  • each container is configured to use HTTPS
  • each container has an aspnetcore app configured to use HTTPS
  • service 1: publish an api to get a random number (or something equally trivial)
  • service 2: publish an api to get weatherforecast; app calls https://service1.local/random to use in weatherforecast
  • service 3: web ui to call https://service2.local/weatherforecast and display the results

Basically a chained series of api calls over https. (generic example of this is authentication with bearer tokens issued from identity server).

Additional Context

The developer community has a common goal of improving the security of applications. We need good examples that demonstrate best practices for common scenarios.

LKujala avatar Sep 09 '23 19:09 LKujala

[Triage]

Great suggestion. This is something that we'd like to get done at some point.

mthalman avatar Sep 13 '23 18:09 mthalman

see https://stackoverflow.com/questions/77063237/how-to-configure-ssl-certificate-in-docker-container for progress (and lack there of) with doing this manually

LKujala avatar Sep 14 '23 19:09 LKujala

Subject: Interested in Working on Docker Containers with HTTPS and HOSTNAME

Hello @mthalman ,

I trust you're well. I wanted to express my interest in contributing to the issue titled "Example of using multiple Docker containers with HTTPS and HOSTNAME." As a C# .NET software engineer with experience in web services, I'm eager to take on this challenge and create a comprehensive guide to help the community understand and implement this scenario effectively.

I'd greatly appreciate it if you could consider assigning this issue to me. I'm excited about the opportunity to work on it and contribute to the community's knowledge base. If you have any specific requirements or guidelines for this task, please feel free to share them, and I'll ensure the documentation meets the project's standards.

Looking forward to the opportunity to collaborate and contribute to this important topic.

Best regards

iamcymentho avatar Oct 23 '23 18:10 iamcymentho

Subject: Interested in Working on Docker Containers with HTTPS and HOSTNAME

Hello @mthalman ,

I trust you're well. I wanted to express my interest in contributing to the issue titled "Example of using multiple Docker containers with HTTPS and HOSTNAME." As a C# .NET software engineer with experience in web services, I'm eager to take on this challenge and create a comprehensive guide to help the community understand and implement this scenario effectively.

I'd greatly appreciate it if you could consider assigning this issue to me. I'm excited about the opportunity to work on it and contribute to the community's knowledge base. If you have any specific requirements or guidelines for this task, please feel free to share them, and I'll ensure the documentation meets the project's standards.

Looking forward to the opportunity to collaborate and contribute to this important topic.

Best regards

Basically, where I got stuck, was importing a cert into a windows docker instance on spin up. There are a number approaches posted in SO; none of these worked for me because 1) they were for linux, or 2) required powershell, or 3) required certmgr utilities. With a full standard OS install, both powershell and certmgr are available. The default docker images are mcr.microsoft.com/dotnet/sdk and mcr.microsoft.com/dotnet/aspnet. for ver 7; have also tried the 8.0-preview-nanoserver-1809 images.

I am sure there is a way to inject the appropriate powershell or utility into the image during spin up; I just dont have time to figure it out.

LKujala avatar Oct 24 '23 18:10 LKujala

@iamcymentho - Thanks very much for the offer. We'd definitely love the help.

This is probably some documentation that should be placed in the samples directory (perhaps in the samples/kubernetes directory if it will be using k8s). Please familiarize yourself with the samples there to get a feel for the style that you can use in your contribution. Some of the requirements:

  • There should be source code included that a user can build to produce the solution.
  • The solution should be as simple as possible but still demonstrates the scenario. Something like a microservice Hello World solution. Avoid having a lot of unnecessary business logic.
  • The documentation should guide the user on the steps necessary to produce the solution on their own machine.

mthalman avatar Nov 03 '23 18:11 mthalman