Debian 11 Bullseye
Sponsored Link

Buildah : Create images from Scratch2021/08/28

 
Create container images from an empty container image.
[1] Start to create with [scratch] image.
# create an empty container with [scratch]

root@dlp:~#
newcontainer=$(buildah from scratch)

root@dlp:~#
buildah containers

CONTAINER ID  BUILDER  IMAGE ID     IMAGE NAME                       CONTAINER NAME
dd2673f1bad6     *     fe3c5de03486 docker.io/library/debian:latest  debian-working-container
6ad9282ae0cc     *     fe3c5de03486 docker.io/library/debian:latest  debian-working-container-1
d72663213be1     *                  scratch                          working-container

# mount [scratch] container

root@dlp:~#
scratchmnt=$(buildah mount $newcontainer)

root@dlp:~#
echo $scratchmnt

/var/lib/containers/storage/overlay/aa8ddf9a3fc5efa5653da2b5d091cfc21759e18c7db1945caf30ce42f98319f6/merged

# install packages to [scratch] container

root@dlp:~#
apt -y install debootstrap

root@dlp:~#
debootstrap bullseye $scratchmnt

# unmount

root@dlp:~#
buildah umount $newcontainer

7dfacaa35c7523d2b82d6f957aad28a8c917ee4d95ebb1d6a1992843f4377788

# run container

root@dlp:~#
buildah run $newcontainer bash

root@d72663213be1:/#
root@d72663213be1:/#
cat /etc/os-release

PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

root@d72663213be1:/#
# add images

root@dlp:~#
buildah commit $newcontainer debian-basic:latest

Getting image source signatures
Copying blob ac373c890fc4 done
Copying config 3cd7af0ea4 done
Writing manifest to image destination
Storing signatures
3cd7af0ea41a46ab0cad5499fda0a20f3b89f4869774f0735c8b1e393e50b571

root@dlp:~#
buildah images

REPOSITORY                 TAG      IMAGE ID       CREATED         SIZE
localhost/debian-basic     latest   3cd7af0ea41a   2 minutes ago   297 MB
localhost/my-debian        latest   7aa4a609ff69   2 hours ago     181 MB
docker.io/library/debian   latest   fe3c5de03486   11 days ago     129 MB

# test to run a container

root@dlp:~#
podman run localhost/debian-basic /bin/echo "Hello my debian"

Hello my debian
Matched Content