podman search で検索できるようにする(レジストリの設定)

CakePHP5 へのマイグレーションついでに docker compose から podman への移行もテストすることにした。

おもむろにインターネットを検索すると多数のページがヒットするが、大抵はハローワールド的に httpd (apache) を動作させているか、cli のコマンドが docker とどれだけ似ているかを確かめるページにぶちあたる。

そういうのはいいんだよ、公式をなぞっているだけでしょ?と文句をいいつつ、むしろ Docker hub からさくっと取ってきてスグに環境作れるってのがどうなるのよ?ってのを知りたいわけだ。

なので、レジストリから検索して pull できるようになるとこまでを晒します。

環境

  • Linux Mint 21.3
  • podman をインストールすると現在 (2024/4/20) バージョン 3.4.4 がインストールされる。

手順

上記のパターンなのかおま環なのかわかりませんが、 registry が設定されていません。なので、 podman search としても虚しく改行されるだけで終わります。
そこで 3.2. コンテナーレジストリーの設定 Red Hat Enterprise Linux 8 | Red Hat Customer Portal に従いレジストリの設定をしていきます。

$ podman info |less 
;; regisries の search が空に設定されていました。

$ touch ~/.config/containers/registries.conf
$ vi ~/.config/containers/registries.conf
unqualified-search-registries = ["registry.access.redhat.com", "registry.redhat.io", "docker.io"]
short-name-mode = "permissive"
:wq

registries となっているとので redhat のもの 2 つ と docker.io を設定したようだ。

nginx を検索するとちゃんと見つかりました。(registry.redhat.io と docker.io で見つかった模様)

$ podman search nginx
INDEX       NAME                                                       DESCRIPTION                                      STARS       OFFICIAL    AUTOMATED
docker.io   docker.io/library/nginx                                    Official build of Nginx.                         19768       [OK]        
docker.io   docker.io/library/unit                                     Official build of NGINX Unit: Universal Web ...  26          [OK]        
docker.io   docker.io/nginx/nginx-ingress                              NGINX and  NGINX Plus Ingress Controllers fo...  89                      
docker.io   docker.io/nginxinc/nginx-unprivileged                      Unprivileged NGINX Dockerfiles                   144                     
docker.io   docker.io/nginx/nginx-prometheus-exporter                  NGINX Prometheus Exporter for NGINX and NGIN...  40                      
docker.io   docker.io/nginxinc/nginx-s3-gateway                        Authenticating and caching gateway based on ...  6                       
docker.io   docker.io/nginx/unit                                       This repository is retired, use the Docker o...  64                      
docker.io   docker.io/nginx/nginx-ingress-operator                     NGINX Ingress Operator for NGINX and NGINX P...  2                       
docker.io   docker.io/nginxinc/amplify-agent                           NGINX Amplify Agent docker repository            1                       
docker.io   docker.io/nginx/nginx-quic-qns                             NGINX QUIC interop                               1                       
docker.io   docker.io/nginxinc/ingress-demo                            Ingress Demo                                     4                       
docker.io   docker.io/nginxproxy/nginx-proxy                           Automated nginx proxy for Docker containers ...  132                     
docker.io   docker.io/nginxproxy/acme-companion                        Automated ACME SSL certificate generation fo...  130                     
docker.io   docker.io/bitnami/nginx                                    Bitnami container image for NGINX                186                     [OK]
docker.io   docker.io/bitnami/nginx-ingress-controller                 Bitnami container image for NGINX Ingress Co...  32                      [OK]
docker.io   docker.io/nginxproxy/docker-gen                            Generate files from docker container meta-da...  16                      
docker.io   docker.io/bitnami/nginx-exporter                           Bitnami container image for NGINX Exporter       5                       
docker.io   docker.io/nginxinc/mra-fakes3                                                                               0                       
docker.io   docker.io/ubuntu/nginx                                     Nginx, a high-performance reverse proxy & we...  112                     
docker.io   docker.io/nginxinc/mra_python_base                                                                          0                       
docker.io   docker.io/nginxinc/ngx-rust-tool                                                                            0                       
docker.io   docker.io/rancher/nginx-ingress-controller                                                                  13                      
docker.io   docker.io/kasmweb/nginx                                    An Nginx image based off nginx:alpine and in...  7                       
docker.io   docker.io/rancher/nginx-ingress-controller-defaultbackend                                                   2                       
redhat.io   registry.redhat.io/rhel8/nginx-114                         Nginx is a web server and a reverse proxy se...  0                       
redhat.io   registry.redhat.io/rhel8/nginx-118                         Platform for running nginx 1.18 or building ...  0                       
redhat.io   registry.redhat.io/ubi8/nginx-120                          Platform for running nginx 1.20 or building ...  0                       
redhat.io   registry.redhat.io/rhel9/nginx-120                         rhcc_registry.access.redhat.com_rhel9/nginx-...  0                       
redhat.io   registry.redhat.io/rhel8/nginx-122                         rhcc_registry.access.redhat.com_rhel8/nginx-...  0                       
redhat.io   registry.redhat.io/rhel8/nginx-116                         Platform for running nginx 1.16 or building ...  0                       
redhat.io   registry.redhat.io/ubi8/nginx-118                          Platform for running nginx 1.18 or building ...  0                       
redhat.io   registry.redhat.io/rhel8/nginx-120                         Platform for running nginx 1.20 or building ...  0                       
redhat.io   registry.redhat.io/ubi9/nginx-120                          rhcc_registry.access.redhat.com_ubi9/nginx-1...  0                       
redhat.io   registry.redhat.io/ubi8/nginx-122                          rhcc_registry.access.redhat.com_ubi8/nginx-1...  0                       
redhat.io   registry.redhat.io/rhel9/nginx-122                         rhcc_registry.access.redhat.com_rhel9/nginx-...  0                       
redhat.io   registry.redhat.io/ubi9/nginx-122                          rhcc_registry.access.redhat.com_ubi9/nginx-1...  0                       
redhat.io   registry.redhat.io/rhscl/nginx-18-rhel7                    Nginx 1.8 server and a reverse proxy server      0                       
redhat.io   registry.redhat.io/rhscl/nginx-112-rhel7                   Nginx is a web server and a reverse proxy se...  0                       
redhat.io   registry.redhat.io/rhscl/nginx-110-rhel7                   Nginx container image that delivers an nginx...  0                       
redhat.io   registry.redhat.io/rhscl/nginx-16-rhel7                    Nginx 1.6 server and a reverse proxy server      0                       
redhat.io   registry.redhat.io/rhscl/nginx-114-rhel7                   Nginx is a web server and a reverse proxy se...  0                       
redhat.io   registry.redhat.io/rhscl/nginx-116-rhel7                   Platform for running nginx 1.16 or building ...  0                       
redhat.io   registry.redhat.io/rhscl/nginx-118-rhel7                   Platform for running nginx 1.18 or building ...  0                       
redhat.io   registry.redhat.io/ubi7/nginx-118                          Platform for running nginx 1.18 or building ...  0                       
redhat.io   registry.redhat.io/rhscl/nginx-120-rhel7                   Platform for running nginx 1.20 or building ...  0                       
redhat.io   registry.redhat.io/ubi7/nginx-120                          Platform for running nginx 1.20 or building ...  0                       
redhat.io   registry.redhat.io/3scale-amp23/apicast-gateway             3scale's API gateway (APIcast) is an OpenRe...  0                       
redhat.io   registry.redhat.io/3scale-amp20/apicast-gateway            3scale's API gateway (APIcast) is an OpenRes...  0                       
redhat.io   registry.redhat.io/rhamp10/apicast-gateway                 3scale's API gateway (APIcast) is an OpenRes...  0  

$ podman pull nginx
Resolved "nginx" as an alias (/home/mnishi/.cache/containers/short-name-aliases.conf)
Trying to pull docker.io/library/nginx:latest...
Getting image source signatures
Copying blob b9d060e68bbc done  
Copying blob 4a666f159bd0 done  
Copying blob c028eb95b065 done  
Copying blob e74ab6743f66 done  
Copying blob c46d32988911 done  
Copying blob 13808c22b207 done  
Copying blob 297a65ba6f04 done  
Copying config 2ac752d7ae done  
Writing manifest to image destination
Storing signatures
2ac752d7aeb1d9281f708e7c51501c41baf90de15ffc9bca7c5d38b8da41b580

pull する時、初回はどのレジストリを使うか選択肢が表示されるが 2 回目は表示されないのでどこかで記憶されているようだ。今回は docker.io を選んだが変えたくなったときにまた調べないといけなそうだ。(キャッシュを消せば OK か ?)

下記の「日記というほどでも」をみると検索の仕方も色々あって公式のみに絞るとかは自分的にはよく使うことになりそう。

追記

github の ghcr.io を追加するには、同様に unqualified-search-registries に “ghcr.io” を追加すれば良いようだ。ただし検索速度がものすごく遅くなるのでやらない方がいいかもしれない。

参考

3.2. コンテナーレジストリーの設定 Red Hat Enterprise Linux 8 | Red Hat Customer Portal

Podmanコマンドで本気でコンテナイメージを探すには | 日記というほどでも