Newsletter
TechAnV Blog
Get updates on security engineering, Rust, eBPF, and DevSecOps. No spam, unsubscribe anytime.
Check your inbox and click the confirmation link to complete your subscription.
Installing packages from Debian unstable in a Docker image based on stable#
For Datasette #1249 I wanted to build a Docker image from the python:3.9.2-slim-buster base image (“buster” is the current stable release of Debian) but include a single package from “sid”, the unstable Debian distribution.
I needed to do this because the latest version of SpatiaLite, version 5, was available in sid but not in buster (which only has 4.3.0a):
https://packages.debian.org/search?keywords=spatialite
![Package libsqlite3-mod-spatialite
stretch (oldstable) (libs): Geospatial extension for SQLite - loadable module
4.3.0a-5+b1: amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64el s390x
buster (stable) (libs): Geospatial extension for SQLite - loadable module
4.3.0a-5+b2: amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64el s390x
bullseye (testing) (libs): Geospatial extension for SQLite - loadable module
5.0.1-2: amd64 arm64 armel armhf i386 mips64el mipsel ppc64el s390x
sid (unstable) (libs): Geospatial extension for SQLite - loadable module
5.0.1-2: alpha amd64 arm64 armel armhf hppa i386 m68k mips64el mipsel ppc64 ppc64el riscv64 s390x sh4 sparc64 x32
experimental (libs): Geospatial extension for SQLite - loadable module
5.0.0~beta0-1~exp2 [debports]: powerpcspe](https://user-images.githubusercontent.com/9599/112061886-5cf77b00-8b1c-11eb-8f4c-91dce388dc33.png)
The recipe that ended up working for me was to install software-properties-common to get the apt-get-repository command, then use that to install a package from sid:
1RUN apt-get update && \2 apt-get -y --no-install-recommends install software-properties-common && \3 add-apt-repository "deb http://httpredir.debian.org/debian sid main" && \4 apt-get update && \5 apt-get -t sid install -y --no-install-recommends libsqlite3-mod-spatialiteHere’s the full Dockerfile I used:
1FROM python:3.9.2-slim-buster as build2
3# software-properties-common provides add-apt-repository4RUN apt-get update && \5 apt-get -y --no-install-recommends install software-properties-common && \6 add-apt-repository "deb http://httpredir.debian.org/debian sid main" && \7 apt-get update && \8 apt-get -t sid install -y --no-install-recommends libsqlite3-mod-spatialite && \9 apt clean && \10 rm -rf /var/lib/apt && \11 rm -rf /var/lib/dpkg12
13RUN pip install datasette && \14 find /usr/local/lib -name '__pycache__' | xargs rm -r && \15 rm -rf /root/.cache/pip16
17EXPOSE 800118CMD ["datasette"]