linux:podman:fedora_ubi_micro

文書の過去の版を表示しています。


Fedora 版の UBI Micro を独自に作る方法 (非公式😅)

AlmaLinux 公式: AlmaLinux/docker-images: Home for AlmaLinux Docker image RootFS files and production version of sources AlmaLinux 9 Dockerfile.micro をダウンロードする🤔

$ curl -LO https://raw.githubusercontent.com/AlmaLinux/docker-images/main/dockerfiles/al9/Dockerfile.micro

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1939  100  1939    0     0   3704      0 --:--:-- --:--:-- --:--:--  3700

Fedora 39 用に修正する😅

$ cp Dockerfile.micro Containerfile.micro
$ nano Containerfile.micro
$ bat -n --pager=never Containerfile.micro

   1 ARG SYSBASE=fedora:39
   2 FROM ${SYSBASE} as system-build
   3 
   4 RUN mkdir -p /mnt/sys-root; \
   5     dnf install --installroot /mnt/sys-root coreutils-single glibc-minimal-langpack \
   6     --releasever 39 --setopt install_weak_deps=false --nodocs -y; \
   7     dnf --installroot /mnt/sys-root clean all;
   8 # Additional hacks for kickstart file and backward compatable support
   9 RUN rm -rf /mnt/sys-root/var/cache/dnf /mnt/sys-root/var/log/dnf* /mnt/sys-root/var/lib/dnf /mnt/sys-root
     /var/log/yum.*; \
  10     /bin/date +%Y%m%d_%H%M > /mnt/sys-root/etc/BUILDTIME ;  \
  11     #echo '%_install_langs C.utf8' > /mnt/sys-root/etc/rpm/macros.image-language-conf; \
  12     echo 'LANG="C.utf8"' >  /mnt/sys-root/etc/locale.conf; \
  13     #echo 'container' > /mnt/sys-root/etc/dnf/vars/infra; \
  14     rm -f /mnt/sys-root/etc/machine-id; \
  15     touch /mnt/sys-root/etc/machine-id; \
  16     touch /mnt/sys-root/etc/resolv.conf; \
  17     touch /mnt/sys-root/etc/hostname; \
  18     touch /mnt/sys-root/etc/.pwd.lock; \
  19     chmod 600 /mnt/sys-root/etc/.pwd.lock; \
  20     rm -rf /mnt/sys-root/usr/share/locale/en* /mnt/sys-root/boot /mnt/sys-root/dev/null /mnt/sys-root/var /log/hawkey.log ; \
  21     echo '0.0 0 0.0' > /mnt/sys-root/etc/adjtime; \
  22     echo '0' >> /mnt/sys-root/etc/adjtime; \
  23     echo 'UTC' >> /mnt/sys-root/etc/adjtime; \
  24     echo '# This file has been generated by the Anaconda Installer.' > /mnt/sys-root/etc/sysconfig/sshd-p ermitrootlogin ;\
  25     echo '# Allow root to log in using ssh. Remove this file to opt-out.' >> /mnt/sys-root/etc/sysconfig/ sshd-permitrootlogin ;\
  26     echo 'PERMITROOTLOGIN="-oPermitRootLogin=yes"' >> /mnt/sys-root/etc/sysconfig/sshd-permitrootlogin ;\
  27     echo 'KEYMAP="us"' > /mnt/sys-root/etc/vconsole.conf; \
  28     echo 'FONT="eurlatgr"' >> /mnt/sys-root/etc/vconsole.conf; \
  29     mkdir -p /mnt/sys-root/run/lock; \
  30     cd /mnt/sys-root/etc ; \
  31     ln -s ../usr/share/zoneinfo/UTC localtime
  32 
  33 FROM scratch
  34 
  35 COPY --from=system-build /mnt/sys-root/ /
  36 
  37 CMD /bin/sh

$ diff Dockerfile.micro Containerfile.micro | bat -n

   1 1c1
   2 < ARG SYSBASE=almalinux:9
   3 ---
   4 > ARG SYSBASE=fedora:39
   5 6c6
   6 <     --releasever 9 --setopt install_weak_deps=false --nodocs -y; \
   7 ---
   8 >     --releasever 39 --setopt install_weak_deps=false --nodocs -y; \
   9 11c11
  10 <     echo '%_install_langs C.utf8' > /mnt/sys-root/etc/rpm/macros.image-language-conf; \
  11 ---
  12 >     #echo '%_install_langs C.utf8' > /mnt/sys-root/etc/rpm/macros.image-language-conf; \
  13 13c13
  14 <     echo 'container' > /mnt/sys-root/etc/dnf/vars/infra; \
  15 ---
  16 >     #echo 'container' > /mnt/sys-root/etc/dnf/vars/infra; \

podman でコンテナをビルドする🤔

$ podman build -t fedora39-micro -f Containerfile.micro .

[1/2] STEP 1/3: FROM fedora:39 AS system-build
[1/2] STEP 2/3: RUN mkdir -p /mnt/sys-root;     dnf install --installroot /mnt/sys-root coreutils-single glibc-minimal-langpack     --releasever 39 --setopt install_weak_deps=false --nodocs -y;     dnf --installroot /mnt/sys-root clean all;
Fedora 39 - x86_64                              349 kB/s |  92 MB     04:28    
Fedora 39 openh264 (From Cisco) - x86_64        1.1 kB/s | 2.6 kB     00:02    
Fedora 39 - x86_64 - Updates                    973 kB/s |  34 MB     00:35    
Last metadata expiration check: 0:00:01 ago on Fri Mar 22 04:48:50 2024.
Dependencies resolved.
================================================================================
 Package                        Arch    Version                  Repo      Size
================================================================================
Installing:
 coreutils-single               x86_64  9.3-5.fc39               updates  636 k
 glibc-minimal-langpack         x86_64  2.38-16.fc39             updates   71 k
Installing dependencies:
 basesystem                     noarch  11-18.fc39               fedora   7.2 k
 bash                           x86_64  5.2.26-1.fc39            updates  1.8 M
 fedora-gpg-keys                noarch  39-1                     fedora   130 k
 fedora-release                 noarch  39-36                    updates  8.6 k
 fedora-release-common          noarch  39-36                    updates   19 k
 fedora-release-identity-basic  noarch  39-36                    updates  9.4 k
 fedora-repos                   noarch  39-1                     fedora   9.3 k
 filesystem                     x86_64  3.18-6.fc39              fedora   1.1 M
 glibc                          x86_64  2.38-16.fc39             updates  2.2 M
 glibc-common                   x86_64  2.38-16.fc39             updates  353 k
 libacl                         x86_64  2.3.1-9.fc39             updates   23 k
 libattr                        x86_64  2.5.1-8.fc39             fedora    18 k
 libcap                         x86_64  2.48-9.fc39              updates   68 k
 libgcc                         x86_64  13.2.1-7.fc39            updates  115 k
 libselinux                     x86_64  3.5-5.fc39               fedora    87 k
 libsepol                       x86_64  3.5-2.fc39               fedora   324 k
 ncurses-base                   noarch  6.4-7.20230520.fc39.1    updates   88 k
 ncurses-libs                   x86_64  6.4-7.20230520.fc39.1    updates  336 k
 pcre2                          x86_64  10.42-1.fc39.2           fedora   233 k
 pcre2-syntax                   noarch  10.42-1.fc39.2           fedora   143 k
 setup                          noarch  2.14.4-1.fc39            fedora   154 k

Transaction Summary
================================================================================
Install  23 Packages

Total download size: 7.8 M
Installed size: 22 M
Downloading Packages:
(1/23): fedora-repos-39-1.noarch.rpm             28 kB/s | 9.3 kB     00:00    
(2/23): basesystem-11-18.fc39.noarch.rpm         16 kB/s | 7.2 kB     00:00    
(3/23): fedora-gpg-keys-39-1.noarch.rpm         204 kB/s | 130 kB     00:00    
(4/23): filesystem-3.18-6.fc39.x86_64.rpm       1.5 MB/s | 1.1 MB     00:00    
(5/23): libattr-2.5.1-8.fc39.x86_64.rpm          28 kB/s |  18 kB     00:00    
(6/23): libselinux-3.5-5.fc39.x86_64.rpm        192 kB/s |  87 kB     00:00    
(7/23): libsepol-3.5-2.fc39.x86_64.rpm          1.2 MB/s | 324 kB     00:00    
(8/23): pcre2-10.42-1.fc39.2.x86_64.rpm         635 kB/s | 233 kB     00:00    
(9/23): pcre2-syntax-10.42-1.fc39.2.noarch.rpm  371 kB/s | 143 kB     00:00    
(10/23): setup-2.14.4-1.fc39.noarch.rpm         658 kB/s | 154 kB     00:00    
(11/23): fedora-release-39-36.noarch.rpm         68 kB/s | 8.6 kB     00:00    
(12/23): fedora-release-common-39-36.noarch.rpm 189 kB/s |  19 kB     00:00    
(13/23): fedora-release-identity-basic-39-36.no  76 kB/s | 9.4 kB     00:00    
(14/23): coreutils-single-9.3-5.fc39.x86_64.rpm 617 kB/s | 636 kB     00:01    
(15/23): glibc-common-2.38-16.fc39.x86_64.rpm   886 kB/s | 353 kB     00:00    
(16/23): bash-5.2.26-1.fc39.x86_64.rpm          965 kB/s | 1.8 MB     00:01    
(17/23): libacl-2.3.1-9.fc39.x86_64.rpm         132 kB/s |  23 kB     00:00    
(18/23): libcap-2.48-9.fc39.x86_64.rpm          272 kB/s |  68 kB     00:00    
(19/23): glibc-minimal-langpack-2.38-16.fc39.x8  64 kB/s |  71 kB     00:01    
(20/23): glibc-2.38-16.fc39.x86_64.rpm          1.0 MB/s | 2.2 MB     00:02    
(21/23): libgcc-13.2.1-7.fc39.x86_64.rpm        318 kB/s | 115 kB     00:00    
(22/23): ncurses-libs-6.4-7.20230520.fc39.1.x86 1.6 MB/s | 336 kB     00:00    
(23/23): ncurses-base-6.4-7.20230520.fc39.1.noa 187 kB/s |  88 kB     00:00    
--------------------------------------------------------------------------------
Total                                           1.4 MB/s | 7.8 MB     00:05     
Fedora 39 - x86_64                              1.6 MB/s | 1.6 kB     00:00    
Importing GPG key 0x18B8E74C:
 Userid     : "Fedora (39) <fedora-39-primary@fedoraproject.org>"
 Fingerprint: E8F2 3996 F232 1864 0CB4 4CBE 75CF 5AC4 18B8 E74C
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-39-x86_64
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Running scriptlet: filesystem-3.18-6.fc39.x86_64                          1/1 
  Preparing        :                                                        1/1 
  Installing       : libgcc-13.2.1-7.fc39.x86_64                           1/23 
  Running scriptlet: libgcc-13.2.1-7.fc39.x86_64                           1/23 
  Installing       : fedora-release-identity-basic-39-36.noarch            2/23 
  Installing       : fedora-gpg-keys-39-1.noarch                           3/23 
  Installing       : fedora-repos-39-1.noarch                              4/23 
  Installing       : fedora-release-common-39-36.noarch                    5/23 
  Installing       : fedora-release-39-36.noarch                           6/23 
  Installing       : setup-2.14.4-1.fc39.noarch                            7/23 
  Running scriptlet: setup-2.14.4-1.fc39.noarch                            7/23 
  Installing       : filesystem-3.18-6.fc39.x86_64                         8/23 
  Installing       : basesystem-11-18.fc39.noarch                          9/23 
  Installing       : ncurses-base-6.4-7.20230520.fc39.1.noarch            10/23 
  Installing       : glibc-minimal-langpack-2.38-16.fc39.x86_64           11/23 
  Installing       : glibc-common-2.38-16.fc39.x86_64                     12/23 
  Running scriptlet: glibc-2.38-16.fc39.x86_64                            13/23 
  Installing       : glibc-2.38-16.fc39.x86_64                            13/23 
  Running scriptlet: glibc-2.38-16.fc39.x86_64                            13/23 
  Installing       : ncurses-libs-6.4-7.20230520.fc39.1.x86_64            14/23 
  Installing       : bash-5.2.26-1.fc39.x86_64                            15/23 
  Running scriptlet: bash-5.2.26-1.fc39.x86_64                            15/23 
  Installing       : libattr-2.5.1-8.fc39.x86_64                          16/23 
  Installing       : libacl-2.3.1-9.fc39.x86_64                           17/23 
  Installing       : libsepol-3.5-2.fc39.x86_64                           18/23 
  Installing       : libcap-2.48-9.fc39.x86_64                            19/23 
  Installing       : pcre2-syntax-10.42-1.fc39.2.noarch                   20/23 
  Installing       : pcre2-10.42-1.fc39.2.x86_64                          21/23 
  Installing       : libselinux-3.5-5.fc39.x86_64                         22/23 
  Installing       : coreutils-single-9.3-5.fc39.x86_64                   23/23 
  Running scriptlet: filesystem-3.18-6.fc39.x86_64                        23/23 
  Running scriptlet: coreutils-single-9.3-5.fc39.x86_64                   23/23 
  Verifying        : basesystem-11-18.fc39.noarch                          1/23 
  Verifying        : fedora-gpg-keys-39-1.noarch                           2/23 
  Verifying        : fedora-repos-39-1.noarch                              3/23 
  Verifying        : filesystem-3.18-6.fc39.x86_64                         4/23 
  Verifying        : libattr-2.5.1-8.fc39.x86_64                           5/23 
  Verifying        : libselinux-3.5-5.fc39.x86_64                          6/23 
  Verifying        : libsepol-3.5-2.fc39.x86_64                            7/23 
  Verifying        : pcre2-10.42-1.fc39.2.x86_64                           8/23 
  Verifying        : pcre2-syntax-10.42-1.fc39.2.noarch                    9/23 
  Verifying        : setup-2.14.4-1.fc39.noarch                           10/23 
  Verifying        : bash-5.2.26-1.fc39.x86_64                            11/23 
  Verifying        : coreutils-single-9.3-5.fc39.x86_64                   12/23 
  Verifying        : fedora-release-39-36.noarch                          13/23 
  Verifying        : fedora-release-common-39-36.noarch                   14/23 
  Verifying        : fedora-release-identity-basic-39-36.noarch           15/23 
  Verifying        : glibc-2.38-16.fc39.x86_64                            16/23 
  Verifying        : glibc-common-2.38-16.fc39.x86_64                     17/23 
  Verifying        : glibc-minimal-langpack-2.38-16.fc39.x86_64           18/23 
  Verifying        : libacl-2.3.1-9.fc39.x86_64                           19/23 
  Verifying        : libcap-2.48-9.fc39.x86_64                            20/23 
  Verifying        : libgcc-13.2.1-7.fc39.x86_64                          21/23 
  Verifying        : ncurses-base-6.4-7.20230520.fc39.1.noarch            22/23 
  Verifying        : ncurses-libs-6.4-7.20230520.fc39.1.x86_64            23/23 

Installed:
  basesystem-11-18.fc39.noarch                                                  
  bash-5.2.26-1.fc39.x86_64                                                     
  coreutils-single-9.3-5.fc39.x86_64                                            
  fedora-gpg-keys-39-1.noarch                                                   
  fedora-release-39-36.noarch                                                   
  fedora-release-common-39-36.noarch                                            
  fedora-release-identity-basic-39-36.noarch                                    
  fedora-repos-39-1.noarch                                                      
  filesystem-3.18-6.fc39.x86_64                                                 
  glibc-2.38-16.fc39.x86_64                                                     
  glibc-common-2.38-16.fc39.x86_64                                              
  glibc-minimal-langpack-2.38-16.fc39.x86_64                                    
  libacl-2.3.1-9.fc39.x86_64                                                    
  libattr-2.5.1-8.fc39.x86_64                                                   
  libcap-2.48-9.fc39.x86_64                                                     
  libgcc-13.2.1-7.fc39.x86_64                                                   
  libselinux-3.5-5.fc39.x86_64                                                  
  libsepol-3.5-2.fc39.x86_64                                                    
  ncurses-base-6.4-7.20230520.fc39.1.noarch                                     
  ncurses-libs-6.4-7.20230520.fc39.1.x86_64                                     
  pcre2-10.42-1.fc39.2.x86_64                                                   
  pcre2-syntax-10.42-1.fc39.2.noarch                                            
  setup-2.14.4-1.fc39.noarch                                                    

Complete!
25 files removed
--> 797c6a64292c
[1/2] STEP 3/3: RUN rm -rf /mnt/sys-root/var/cache/dnf /mnt/sys-root/var/log/dnf* /mnt/sys-root/var/lib/dnf /mnt/sys-root/var/log/yum.*;     /bin/date +%Y%m%d_%H%M > /mnt/sys-root/etc/BUILDTIME ;      echo 'LANG="C.utf8"' >  /mnt/sys-root/etc/locale.conf;     rm -f /mnt/sys-root/etc/machine-id;     touch /mnt/sys-root/etc/machine-id;     touch /mnt/sys-root/etc/resolv.conf;     touch /mnt/sys-root/etc/hostname;     touch /mnt/sys-root/etc/.pwd.lock;     chmod 600 /mnt/sys-root/etc/.pwd.lock;     rm -rf /mnt/sys-root/usr/share/locale/en* /mnt/sys-root/boot /mnt/sys-root/dev/null /mnt/sys-root/var/log/hawkey.log ;     echo '0.0 0 0.0' > /mnt/sys-root/etc/adjtime;     echo '0' >> /mnt/sys-root/etc/adjtime;     echo 'UTC' >> /mnt/sys-root/etc/adjtime;     echo '# This file has been generated by the Anaconda Installer.' > /mnt/sys-root/etc/sysconfig/sshd-permitrootlogin ;    echo '# Allow root to log in using ssh. Remove this file to opt-out.' >> /mnt/sys-root/etc/sysconfig/sshd-permitrootlogin ;    echo 'PERMITROOTLOGIN="-oPermitRootLogin=yes"' >> /mnt/sys-root/etc/sysconfig/sshd-permitrootlogin ;    echo 'KEYMAP="us"' > /mnt/sys-root/etc/vconsole.conf;     echo 'FONT="eurlatgr"' >> /mnt/sys-root/etc/vconsole.conf;     mkdir -p /mnt/sys-root/run/lock;     cd /mnt/sys-root/etc ;     ln -s ../usr/share/zoneinfo/UTC localtime
--> de30b452c739
[2/2] STEP 1/3: FROM scratch
[2/2] STEP 2/3: COPY --from=system-build /mnt/sys-root/ /
--> c6dec1882de0
[2/2] STEP 3/3: CMD /bin/sh
[2/2] COMMIT fedora39-micro
--> 86c23be19d22
Successfully tagged localhost/fedora39-micro:latest
86c23be19d2294d4438728b311652ed0da8772fc68f1bf2d08d65790dcf216e5

18.99MB のマイクロコンテナができる🤔 (未テスト無保証です😅)

$ podman image tree localhost/fedora39-micro

Image ID: 86c23be19d22
Tags:     [localhost/fedora39-micro:latest]
Size:     18.99MB
Image Layers
└── ID: a74141c1611a Size: 18.99MB Top Layer of: [localhost/fedora39-micro:latest]

参考…🤔

$ podman image tree registry.access.redhat.com/ubi9/ubi-micro:9.3

Image ID: 0a76a9bf80ab
Tags:     [registry.access.redhat.com/ubi9/ubi-micro:9.3]
Size:     23.26MB
Image Layers
└── ID: f6e375c0d5ad Size: 23.25MB Top Layer of: [registry.access.redhat.com/ubi9/ubi-micro:9.3]

$ podman image tree quay.io/almalinuxorg/9-micro

Image ID: 7655ca68de74
Tags:     [quay.io/almalinuxorg/9-micro:latest]
Size:     20.64MB
Image Layers
└── ID: 51f63efb5d73 Size: 20.64MB Top Layer of: [quay.io/almalinuxorg/9-micro:latest]

  • linux/podman/fedora_ubi_micro.1711084320.txt.gz
  • 最終更新: 2024/03/22 14:12
  • by ともやん