I want to automatically rebuild my Docker containers when their base image changed. The idea is to compare the base image ID of the current tagged container to the ID of the base image in Docker Hub and run a new build if it differs.
Getting the latest base image ID seems to be quite straight forward:
$ docker pull debian:latest >/dev/null 2&>1; docker images debian:latest -q
sha256:a20fd0d59cf13f82535ccdda818d70b97ab043856e37a17029e32fc2252b8c56
docker inspect
has an entry called "Parent" that seems to contain the ID of the image used in the FROM
directive:
$ docker inspect -f '{{.Parent}}' dockertest-1
sha256:a20fd0d59cf13f82535ccdda818d70b97ab043856e37a17029e32fc2252b8c56
Since I can't really find any documentation about this I wonder if I should rely on this data to build my build pipeline.