.NET Core/Linux - Get Docker container ID in code

I have the need to log the container ID my app is running in. Is there a way to get this via C#?

Found the answer, you can simply request System.Environment.MachineName which will return the GUID of the container.

1 Like

Is it possible to get container name instead of container id?