Why is a certain Docker RUN command not cached?
13:27 23 Jun 2026

I try to create a Dockerfile that should allow me to do some cross-compilation. This implies building larger software packages like boost or Qt and while I try to get it right it fails a lot of times.

Part of the Dockerfile looks like this:

FROM gcc:12.1.0-bullseye
...
RUN apt-get -y install ninja-build

RUN git clone --branch v6.11.1 git://code.qt.io/qt/qt5.git qt
RUN cd qt && ./init-repository --module-subset=essential -f

# Creating the minimum host build of Qt
RUN mkdir ~/QtHostBuild
RUN cd ~/QtHostBuild && qt/configure -developer-build -nomake tests
RUN cd ~/QtHostBuild && cmake --build . --target host_tools

the ./init-repository ... takes ages (20 minutes) but runs without problem. The execution of that line is a predicate for later commands. What do I need to do to have the execution of the line be cached?

The container is built with:

docker buildx build --platform=linux/amd64 -t windows_build_amd64 -f DockerfileWindows /Users/todi/bootloader --output type=docker
docker docker-run docker-cache