Custom Debian container

Debian containers can be easily built using debootstrap to create a basic Debian chroot, which can then be cleaned up and tared to add to a Containerfile.

The following is the process:

sudo apt-get install debootstrap
sudo mkdir -p /opt/mydebian/rootfs
cd /opt/mydebian
sudo debootstrap stable ./rootfs http://deb.debian.org/debian
sudo rm -fr ./rootfs/debootstrap
sudo rm -fr ./rootfs/var/cache/*
sudo rm -fr ./rootfs/var/lib/apt/lists/*
sudo tar czf rootfs.tar.gz -C ./rootfs .
cat << __EOF__ | sudo tee Containerfile
FROM scratch
ADD rootfs.tar.gz /
CMD ["/bin/bash"]
__EOF__
podman build -t mydebian:latest .

This will create a podman image tagged mydebian:latest with the current stable packages.