Skip to content

Instantly share code, notes, and snippets.

@sepastian
Created September 19, 2025 13:46
Show Gist options
  • Save sepastian/2fbaec09a75da3090ec71af8b9b2eff9 to your computer and use it in GitHub Desktop.
Save sepastian/2fbaec09a75da3090ec71af8b9b2eff9 to your computer and use it in GitHub Desktop.
Build Docker images using archived Debian base image

When maintaining code and, successively, building old (10+ years) Dockerfile images, problems may arise because the base image may be based off a Debian distribution, which is no longer available. I.e. /etc/apt/sources.list cointains references, which no longer exist. For example, ruby:2.3 is based off Debian 9 (stretch), as can be seen.

# # cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

What to do? Debian Archives to the rescue, see https://www.debian.org/distrib/archive.

When a Debain distribution reaches EOL, it does not get deleted but, instead, is moved to archive.

So, the solution is to replace the existing /etc/apt/sources.list and reference the Debian Archive.

For example, to use stretch (Debian 9) in 2025, create the following sources.list file.

# $ cat files/web/etc/apt/sources.list 
deb http://archive.debian.org/debian/ stretch main non-free contrib
deb-src http://archive.debian.org/debian/ stretch main non-free contrib

deb http://archive.debian.org/debian-security/ stretch/updates main non-free contrib
deb-src http://archive.debian.org/debian-security/ stretch/updates main non-free contrib

Inside Dockerfile, replace the existing /etc/apt/sources.list. When running apt-get subsequently, one may have to add the --allow-unauthenticated switch.

FROM ruby:2.3
COPY sources.list /etc/apt/sources.list
RUN apt-get update -qq && apt-get install -y --allow-unauthenticated nodejs postgresql-client sendmail
:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment