microsoft / DockerTools

Tools For Docker, including Visual Studio Provisioning and Publishing
Other
175 stars 26 forks source link

What new samples would be most useful? #353

Closed NCarlsonMSFT closed 1 year ago

NCarlsonMSFT commented 2 years ago

I'm considering setting some time aside to write some new samples and wondered if anyone has requests. For reference here is the last sample I wrote up: https://github.com/NCarlsonMSFT/CertExample Are there other scenarios like secure service to service communication, where it would help to have a sample on how to get working?

igorrates commented 1 year ago

It would be nice to see an example where I can set a custom host to the container for debugging. Today I can have something like this at the end of my DockerFile to set a custom host:

CMD ["/bin/bash", "/add-hosts-and-start-app.sh", "my.host.com"]

And the script looks like this to add the new host to the hosts file at runtime:

#!/bin/bash

# Get the container's IP address
CONTAINER_IP=$(hostname -i)

# Get the domain name from the first command-line argument
DOMAIN_NAME="$1"

# Append the domain name to the IP address
HOSTS_ENTRY="$CONTAINER_IP    $DOMAIN_NAME"

echo "$HOSTS_ENTRY"

# Add the entry to the /etc/hosts file
echo "$HOSTS_ENTRY" >> /etc/hosts

# Start application with the LocalHTTPS launch profile
dotnet "my-app.dll" --launch-profile LocalHTTPS

My problem becomes when I need to add that custom host for debugging: I can't use the tag on csproj <DockerfileRunArguments>-p 5007:5007 --network endor-net --add-host=my.host.com:<The IP></DockerfileRunArguments> I'm afraid I don't know the IP previously the container will take. I have multiple services that can be run on their own containers.