<p>We deploy our dockerized java applications to our various environments via kubernetes. We have a need to provide the podID to each docker container inside the pod. </p>

<p>Update: so I should have been more clear. I know already from this handy link from an old posting <a href="https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/" rel="nofollow noreferrer">Downward API</a> , that I can retrieve the podID value during configuration of deploying container this way:</p>

<pre><code>  env:
    - name: MY_POD_IP
      valueFrom:
        fieldRef:
          fieldPath: status.podIP
</code></pre>

<p>My question is how can I either pass this id to the docker container, OR, just as good, is there a way the container can retrieve this information from it's kubernetes context/environment?</p>

<p>Thanks for any insights</p>

Timothy Clotworthy
<p>As you mentioned, you do this by using the Downward API, let me try and explain:</p>

<p>When defining this stanza in your pod yaml:</p>

<pre><code>- name: MY_POD_IP
  valueFrom:
    fieldRef:
      fieldPath: status.podIP
</code></pre>

<p><strong>You get the pod IP via an environment variable name <code>MY_POD_IP</code> inside your container</strong></p>
