<p>We are using Dockers and Kubernetes to containerize my .Net web application and scale up to 8-9 replicas. So we installed Dockers (in my Win 10 machine) and used Linux containers.</p>
<p>Orchestration is done by Kubernetes. I would like to get the name/id of the container in which my web application is running to serve the current user request.</p>
<p>Could not find a way to get the id/name of the container from my .Net Web application. Please share me your thoughts on this.</p>
<p>Regards</p>

Hari
<p>You can expose Pod fields as environment variables, the field <code>metadata.name</code> will contain the name of the Pod.</p>

<p>Documentation and example: <a href="https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/#use-container-fields-as-values-for-environment-variables" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/#use-container-fields-as-values-for-environment-variables</a></p>

<p>Edit:
You can also use <code>System.Environment.MachineName</code> as @vahdet commented earlier. The hostname of the container is the pod id.</p>
