title: Get docker image digest / hash from within the container
body: <p>I know it is possible to access the docker api and the following command works just fine:<br>
  <code>curl -s --unix-socket /var/run/docker.sock http:/v1.24/containers/$HOSTNAME/json | jq -r '.Image'
  </code> </p>
  
  <p>However, I would really like avoid exposing the <code>docker.sock</code> to the container itself because it is part of a CI build. Is there any other way of retrieving the container image id / hash (i.e. <code>2acdef41a0c</code>) from within a container itself without exposing the <code>docker.sock</code> and making a <code>curl</code> request to it? </p>
  
  <p>Maybe something like what's shown here <a href="https://stackoverflow.com/a/25729598/393805">Docker, how to get container information from within the container</a> ?</p>