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:

  • Setting up a pycharm license server
  • Haproxy and intermittent 503 issues
  • Running Chromium inside Docker - Gtk: cannot open display: :0
  • Why is my Redis Python setup inserting values multiple times when a command is called once?
  • Files not visible to Jenkins running in Docker
  • MongoDB auto reconnect with docker + node.js + mongodb
  • 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

  • Postgresql 9.6 initdb fails in Centos 7 docker container
  • Docker not starting with docker start command in 1.3
  • How to get the mapped port on host from a docker container?
  • Flask application on Docker with Let's Encrypt
  • Exception in thread “main” java.lang.RuntimeException: Failed to reset file system
  • Command docker run create empty container
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.