Accessing the image hash from within the container

Is is possible to access the hash-ID of the image used to create the container, from within the container? I want to provide a ‘signature version’ at the bottom of each page served from a php app running in a container.

I guess one way is to use Environment Variables from within the docker compose file:

  • Is it possible to restrict access to lxc containers?
  • Error when creating a MySQL database in a Dockerfile
  • Localhost doesn't forward requests to oracle docker container
  • restarting bitcoin tesnet docker container, error flag '-ti'
  • Enable Remote API on Docker hosts in Ubuntu 14
  • How do I integrate my git PHP repo into an official Docker Hub container?
  • environment:
          - IMAGE_HASH=${IMAGE_HASH}

    and then have a wrapper script first of all write the IMAGE_HASH=ABC123 to a .env file before running docker-compose up. The script can inspect the image to get the hash ID.

    But I wonder if there is a ‘proper’ way to do this? So from within the compose file something like:

        - IMAGE_HASH=this.imagehash

  • Sending data from one pod to another pod running specifically on the same host (DaemonSet)
  • Kafka in Kubernetes Cluster- How to publish/consume messages from outside of Kubernetes Cluster
  • Docker login working only with daemon but not with Docker active service
  • Jenkins Docker Pipeline Exit Code -1
  • Docker EXPOSE. Can't get it
  • How to send the parameters to command in docker with --entrypoint
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.