diff --git a/docker/pipeline/Dockerfile b/docker/pipeline/Dockerfile
index bfeba56f65ec428c1522449c17a7662b29c81e41..8e7d931bba808275811aad0e7ec3f955b5374868 100644
--- a/docker/pipeline/Dockerfile
+++ b/docker/pipeline/Dockerfile
@@ -37,7 +37,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
 
 # Prepare the environment for installing the Rapthor source dependencies.
 WORKDIR /src
-RUN git config --global alias.shallow-clone "!git clone --depth 1 --recurse-submodules --shallow-submodules"
 
 # By default, build non-portable code, for the oldest CPU that supports AVX2
 ARG PORTABLE=FALSE
@@ -64,7 +63,9 @@ wget -qO - https://www.astron.nl/iers/WSRT_Measures.ztar | \
     tar -C /usr/local/share/casacore/data -xzf -
 
 # Install casacore
-RUN git shallow-clone https://github.com/casacore/casacore.git
+ARG CASACORE_COMMIT=master
+RUN git clone --no-checkout https://github.com/casacore/casacore.git
+RUN git -C casacore checkout ${CASACORE_COMMIT}
 RUN cmake \
     -DCMAKE_BUILD_TYPE:STRING=Release \
     -DPORTABLE=${PORTABLE} \
@@ -75,7 +76,9 @@ RUN cmake \
 RUN ninja -C /src/casacore/build install
 
 # Install LofarStMan
-RUN git shallow-clone https://github.com/lofar-astron/LofarStMan
+ARG LOFARSTMAN_COMMIT=main
+RUN git clone --no-checkout https://github.com/lofar-astron/LofarStMan.git
+RUN git -C LofarStMan checkout ${LOFARSTMAN_COMMIT}
 RUN cmake \
     -DCMAKE_BUILD_TYPE:STRING=Release \
     -DPORTABLE=${PORTABLE} \
@@ -88,7 +91,9 @@ RUN ninja -C /src/LofarStMan/build install
 # Install EveryBeam
 # Do not compile python bindings, they will interfere with the ones in the
 # binary wheel on PyPI.
-RUN git shallow-clone https://git.astron.nl/RD/EveryBeam.git
+ARG EVERYBEAM_COMMIT=master
+RUN git clone --no-checkout https://git.astron.nl/RD/EveryBeam.git
+RUN git -C EveryBeam checkout ${EVERYBEAM_COMMIT}
 RUN cmake \
     -DCMAKE_BUILD_TYPE:STRING=Release \
     -DBUILD_WITH_PYTHON=OFF \
@@ -101,7 +106,9 @@ RUN cmake \
 RUN ninja -C /src/EveryBeam/build install
 
 # Install AOFlagger
-RUN git shallow-clone https://gitlab.com/aroffringa/aoflagger.git
+ARG AOFLAGGER_COMMIT=master
+RUN git clone --no-checkout https://gitlab.com/aroffringa/aoflagger.git
+RUN git -C aoflagger checkout ${AOFLAGGER_COMMIT}
 RUN cmake \
     -DCMAKE_BUILD_TYPE:STRING=Release \
     -DPORTABLE=${PORTABLE} \
@@ -112,7 +119,9 @@ RUN cmake \
 RUN ninja -C /src/aoflagger/build install
 
 # Install SAGECal libdirac
-RUN git shallow-clone https://github.com/nlesc-dirac/sagecal.git
+ARG SAGECAL_COMMIT=master
+RUN git clone --no-checkout https://github.com/nlesc-dirac/sagecal.git
+RUN git -C sagecal checkout ${SAGECAL_COMMIT}
 RUN cmake \
     -DCMAKE_BUILD_TYPE:STRING=Release \
     -DLIB_ONLY=1 \
@@ -123,7 +132,9 @@ RUN cmake \
 RUN ninja -C /src/sagecal/build install
 
 # Install DP3
-RUN git shallow-clone https://git.astron.nl/RD/DP3.git
+ARG DP3_COMMIT=master
+RUN git clone --no-checkout https://git.astron.nl/RD/DP3.git
+RUN git -C DP3 checkout ${DP3_COMMIT}
 RUN cmake \
     -DCMAKE_BUILD_TYPE:STRING=Release \
     -DBUILD_TESTING=OFF \
@@ -137,7 +148,9 @@ RUN cmake \
 RUN ninja -C /src/DP3/build install
 
 # Install python-casacore
-RUN git clone https://github.com/casacore/python-casacore.git
+ARG PYTHON_CASACORE_COMMIT=master
+RUN git clone --no-checkout https://github.com/casacore/python-casacore.git
+RUN git -C python-casacore checkout ${PYTHON_CASACORE_COMMIT}
 RUN CASACORE_DATA=/usr/local/share/casacore/data \
     python3 -m pip install -v /src/python-casacore
 
@@ -159,6 +172,26 @@ FROM ubuntu:22.04 AS runner
 
 COPY --from=builder /usr/local /usr/local
 
+# Repeat version arguments for the runner
+ARG \
+    LOFARSTMAN_COMMIT=main \
+    CASACORE_COMMIT=master \
+    EVERYBEAM_COMMIT=master \
+    AOFLAGGER_COMMIT=master \
+    SAGECAL_COMMIT=master \
+    DP3_COMMIT=master \
+    PYTHON_CASACORE_COMMIT=master
+
+# Add version information to the metadata of the image
+LABEL \
+    nl.astron.preprocess.lofarstman.version=${LOFARSTMAN_COMMIT} \
+    nl.astron.preprocess.casacore.version=${CASACORE_COMMIT} \
+    nl.astron.preprocess.everybeam.version=${EVERYBEAM_COMMIT} \
+    nl.astron.preprocess.aoflagger.version=${AOFLAGGER_COMMIT} \
+    nl.astron.preprocess.sagecal.version=${SAGECAL_COMMIT} \
+    nl.astron.preprocess.dp3.version=${DP3_COMMIT} \
+    nl.astron.preprocess.python-casacore.version=${PYTHON_CASACORE_COMMIT}
+
 # Only install run-time required packages
 RUN export DEBIAN_FRONTEND=noninteractive && \
     apt-get update && \