<p>I'm using Kubernetes+Helm - and wanting to ask if it possible to get the Docker version as specified in the spec containers. So forexample, I have the deployment below:</p>

<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      labels:
        app: test
    spec:
      containers:
        - name: test
          image: myrepo.com/animage:0.0.3
          imagePullPolicy: Always
          command: ["/bin/sh","-c"]
          args: [“work”]
          envFrom:
          - configMapRef:
              name: test
</code></pre>

<p>I then have another deployment where I would like to get that Docker version number 0.0.3 and set it as an env var.</p>

<p>Any ideas appreciated.</p>

<p>Thanks.</p>

userMod2
<p>Short answer: No. At least not directly. Although there are two workarounds I can see that you might find viable.</p>

<hr>

<p>First, apart of providint image with your version tag, set a label/annotation on the pod indicating it's version and use Downward API to pass that data down to your container</p>

<p><a href="https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/</a></p>

<p><a href="https://kubernetes.io/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/</a></p>

<hr>

<p>Second, if you actually own the process to build that image, you can easily bake the version in during docker build with something like :</p>

<p>Dockerfile:</p>

<pre><code>FROM ubuntu
ARG VERSION=undefined
ENV VERSION=$VERSION
</code></pre>

<p>with build command like </p>

<p><code>docker build --build-arg VERSION=0.0.3 -t myrepo.com/animage:0.0.3 .</code></p>

<p>which will give you an image with a baked in env var with your version value</p>
