I got stuck pushing a Docker image to GitHub Container Registry (ghcr.io) and then building and using another Docker image that references it, so I’m making a note.
Setup
Base Docker image
ghcr.io/username/child:latest
FROM python:3.8-slim
RUN echo "foo"
Docker image that references the base Docker image
ghcr.io/username/parent:latest
FROM ghcr.io/username/child:latest
# install various things
The problem
The Docker image used in production
FROM ghcr.io/username/parent:latest
# build various things
RUN python -v
In this state, checking the Python version shows 3.8.
To update the Python version, I updated the Dockerfile for ghcr.io/username/child:latest.
+ FROM python:3.9-slim
RUN echo "foo"
When I rebuilt the production Docker image, the Python version was still 3.8.
The cause
Even if you set the base image to latest, it does not always pull the newest image.
It pulls the latest image as it was at the time that Dockerfile was built.
So when you update the base Docker image, you also need to rebuild the Docker image that references the base Docker image.
It’s obvious in hindsight, but it was the first time it caught me out.
Summary
The last place you look.