TIL: Dockerfile Heredocs#

I did not even know that Docker has support for heredocs until today.

Then I read the official blog post from 2021. In my defense: Using this depends on buildkit, which only became default in Docker Engine v23 released in 2023.

Here is how I use it:

FROM python:3.12.1-slim-bookworm AS base
ARG DEBIAN_FRONTEND=noninteractive

RUN <<EOF
apt-get update
apt-get install -y --no-install-recommends \
  bash \
  bash-completion \
  ca-certificates \
  locales
rm -rf /var/lib/apt/lists/*
EOF

🖖

Contact

Notes? Comments? Feel free to contact me on The Matrix.