Ubuntu 24.04
Sponsored Link

Buildah : Create images from Scratch2024/05/13

 
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
cc1b24f376c9     *     bf3dc08bfed0 docker.io/library/ubuntu:latest  ubuntu-working-container
6d38de367b81     *     bf3dc08bfed0 docker.io/library/ubuntu:latest  ubuntu-working-container-1
7f0b7b799991     *                  scratch                          working-container

# mount [scratch] container

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

root@dlp:~#
echo $scratchmnt

/var/lib/containers/storage/overlay/5f7c39ce2cc455414777cbcda49be2a20af4e3439b1031551a79bb16f6b5fe19/merged

# install packages to [scratch] container

root@dlp:~#
apt -y install debootstrap

root@dlp:~#
debootstrap noble $scratchmnt

# unmount

root@dlp:~#
buildah umount $newcontainer

7f0b7b799991139a12fe6fb5a8d2cc9d768b124f5d1a62b21ba7d8114c89b455

# run container

root@dlp:~#
buildah run $newcontainer cat /etc/os-release

PRETTY_NAME="Ubuntu 24.04 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo

# add images

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

Getting image source signatures
Copying blob 8bb68f0e0f1f done   |
Copying config 58dcc2b741 done   |
Writing manifest to image destination
58dcc2b74169547109cac460bdd36b783fd4f6bf6839e478746d74b8e61e8af7

root@dlp:~#
buildah images

REPOSITORY                 TAG      IMAGE ID       CREATED          SIZE
localhost/ubuntu-basic     latest   58dcc2b74169   26 seconds ago   410 MB
localhost/my-ubuntu        latest   8f4619e42cf0   11 minutes ago   158 MB
docker.io/library/ubuntu   latest   bf3dc08bfed0   13 days ago      78.7 MB

# test to run a container

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

Hello my debian
Matched Content