文書の過去の版を表示しています。
podman ローカル プライベート レジストリの構築
インストール
$ sudo dnf install -y podman httpd-tools
メタデータの期限切れの最終確認: 1:14:37 前の 2024年03月19日 06時13分34秒 に実施しました。 パッケージ podman-5:4.9.3-1.fc39.x86_64 は既にインストールされています。 パッケージ httpd-tools-2.4.58-1.fc39.x86_64 は既にインストールされています。 依存関係が解決しました。 行うべきことはありません。 完了しました!
レジストリ構築
レジストリ用のディレクトリを作成🤔
$ sudo mkdir -p /var/lib/registry/{auth,certs,data} && sudo ls -al /var/lib/registry
合計 0 drwxr-xr-x 1 root root 26 3月 19 07:36 . drwxr-xr-x. 1 root root 1042 3月 19 07:36 .. drwxr-xr-x 1 root root 0 3月 19 07:36 auth drwxr-xr-x 1 root root 0 3月 19 07:36 certs drwxr-xr-x 1 root root 0 3月 19 07:36 data
レジストリ認証用の htpasswd ファイルを作成🤔
$ sudo htpasswd -cB /var/lib/registry/auth/htpasswd tomoyan
New password: password 入力 Re-type new password: 確認 password 入力 Adding password for user tomoyan
$ sudo bat -n /var/lib/registry/auth/htpasswd
1 tomoyan:$2y$05$MO8AFjpgWM5mVvYxbDpeIeWntMr0jxkkQ6krWEZ04n39RA73F2PWC
htpasswd の使い方 🤤
$ htpasswd
Usage:
htpasswd [-cimBdpsDv] [-C cost] passwordfile username
htpasswd -b[cmBdpsDv] [-C cost] passwordfile username password
htpasswd -n[imBdps] [-C cost] username
htpasswd -nb[mBdps] [-C cost] username password
-c Create a new file.
-n Don't update file; display results on stdout.
-b Use the password from the command line rather than prompting for it.
-i Read password from stdin without verification (for script usage).
-m Force MD5 encryption of the password (default).
-2 Force SHA-256 crypt() hash of the password (very secure).
-5 Force SHA-512 crypt() hash of the password (very secure).
-B Force bcrypt encryption of the password (very secure).
-C Set the computing time used for the bcrypt algorithm
(higher is more secure but slower, default: 5, valid: 4 to 17).
-r Set the number of rounds used for the SHA-256, SHA-512 algorithms
(higher is more secure but slower, default: 5000).
-d Force CRYPT encryption of the password (8 chars max, insecure).
-s Force SHA-1 encryption of the password (insecure).
-p Do not encrypt the password (plaintext, insecure).
-D Delete the specified user.
-v Verify password for the specified user.
On other systems than Windows and NetWare the '-p' flag will probably not work.
The SHA-1 algorithm does not use a salt and is less secure than the MD5 algorithm.
使用法:
htpasswd [-cimBdpsDv] [-C cost] passwordfile username
htpasswd -b[cmBdpsDv] [-C cost] passwordfile username password
htpasswd -n[imBdps] [-C cost] username
htpasswd -nb[mBdps] [-C cost] username password
-c 新しいファイルを作成します。
-n ファイルを更新しません。結果を標準出力に表示します。
-b パスワードを要求するのではなく、コマンドラインからパスワードを使用します。
-i 検証なしで標準入力からパスワードを読み取ります (スクリプト使用のため)。
-m パスワードの MD5 暗号化を強制します (デフォルト)。
-2 パスワードの SHA-256 crypt() ハッシュを強制します (非常に安全)。
-5 パスワードの SHA-512 crypt() ハッシュを強制します (非常に安全)。
-B パスワードの bcrypt 暗号化を強制します (非常に安全です)。
-C bcrypt アルゴリズムに使用される計算時間を設定します。
(値が高いほど安全ですが速度は遅くなります、デフォルト: 5、有効: 4 ~ 17)。
-r SHA-256、SHA-512 アルゴリズムに使用されるラウンド数を設定します。
(値が高いほど安全性は高くなりますが、速度は遅くなります。デフォルト: 5000)。
-d パスワードの CRYPT 暗号化を強制します (最大 8 文字、安全ではありません)。
-s パスワードの SHA-1 暗号化を強制します (安全ではありません)。
-p パスワードを暗号化しません (平文、安全ではありません)。
-D 指定したユーザーを削除します。
-v 指定されたユーザーのパスワードを確認します。
Windows および NetWare 以外のシステムでは、'-p' はおそらくフラグは機能しないでしょう。
SHA-1 アルゴリズムはソルトを使用しないため、MD5 アルゴリズムよりも安全性が低くなります。
自己署名証明書の生成🤔
$ sudo openssl req -newkey rsa:4096 -nodes -sha256 -keyout /var/lib/registry/certs/domain.key -x509 -days 365 -out /var/lib/registry/certs/domain.crt
...+.......+........+.+........+++++++++++++++++++++++++++++++++++++++++++++*.......+...+..+...+...........................+..........+...+......+..+.......+..+.+...+..+....+.....+......+...+++++++++++++++++++++++++++++++++++++++++++++*.....+............+...+............+...+....+....................+.+...+...........+.............+...........+......+......+.......+...+..................+......+...+...........+....+...........+.......+..+.+.........+...+.....+....+......+.....+.........+.+...+.........+...........+...............+.....................+....+..+...+......+...+......+..........+.....+....+..+..........+........+......+....+.....+.............+.........+......+...+.....+......+..........+...+..................+..+...+.......+..+...+.+...............+......+.........+......+.....+...+......+.+........+......+.......+...+............+...+....................+.........+..........+.....+.......+......+.....+.......+...............+......+..+.........+...+...+....+...+...........+...............+....+...+...+......+.........+...........+.+.......................+....+........+.............+......+......+..+...+....+..............+.+...........+......................+...+............+..+....+.........+..+..................+...+...+.........+................+.....+......+.+.........+.....+...............+......+............+...+....+...............+...+.................+.+...+.....+.+...+...+.....+...+......+.+...+...........+...+.......+........+.+............+...+..+..........+..............+...+......+.+...+..+...+......+.......+..................+...........+..........+...............+......+..............................+.....+...............+.........+...................+.........+...+...+.....+.+...............+.....................+..+...+.......+......+..+...............+.............+......+......+..+...............+................+..+...+....+.....+......+.+.........+..+..........+.................+.+.........+......+...........+..........+.........+..+..........+...............+.....+.........+..........+.....+...+.+...............+..+..........+.........+.....+.............+........+....+...+...........+....+..+..........+.....+...+.....................+.......+..+.....................................+.........+..+.......+.....+...+.........................+.........+........+.+.....+.+......+........+....+..+.+.....+......................+......+.................+.............+.............................+.+..+...+......+.+.....+....+..................+.....+..........+..+..................................+.....+............+.........+................+............+.....+..........+......+.....+....+...+..+......+.......+..+.......+......+...+......+...........+...+....+..+.+..................+......+........+......+.+...........+............+............+....+..+..........+..+......+............+.......+......+.................+...+.......+..............+.+..............+.+..+.+.........+.....+...+...+......+.+............+..+...............+....+..+++++ ...+......+....+..+.+..+......+.......+..+..........+........+...+.+......+............+..+++++++++++++++++++++++++++++++++++++++++++++*..................+++++++++++++++++++++++++++++++++++++++++++++*...................+...+.....+.........+.............+............+..................+............+......+......+...+......+.....+....+...+..............+.+...+.....+.+...+.................+......+.......+........+.........+...+.+..+...+.+......+.........+...+...+........+.......+...+............+.....+..........+........+....+...+............+..+..................+............+..........+.....+......+....+....................+.+.................+...+............+.......+...+.................+.+.........+........+.+..+.........+...+......+.......+.....+..........+.....+....+.....+.........................+.....+....+...........+.........+.........+......+....+...........+....+...+...+......+.....+......+.................................+.+........+.+..+....+...........+.......+..+...............+.+.........+...........+.......+........+.........+...+.+.....+.+++++ ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. -----
Country Name (2 letter code) [XX]:JP State or Province Name (full name) []:Hokkaido Pref. Locality Name (eg, city) [Default City]:Sapporo City Organization Name (eg, company) [Default Company Ltd]:Monster's Garage Co.,Ltd. Organizational Unit Name (eg, section) []:- Common Name (eg, your name or your server's hostname) []:wicked-beat.fireball.local Email Address []:domain-admin@tomoyan.net
ホストでの証明書の信頼🤔
$ sudo cp /var/lib/registry/certs/domain.crt /etc/pki/ca-trust/source/anchors/ $ sudo update-ca-trust $ trust list | grep -i "wicked-beat.fireball.local"
label: wicked-beat.fireball.local
レジストリの起動
$ sudo podman run --name myregistry \ -p 5000:5000 \ -v /var/lib/registry/data:/var/lib/registry:z \ -v /var/lib/registry/auth:/auth:z \ -e "REGISTRY_AUTH=htpasswd" \ -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \ -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \ -v /var/lib/registry/certs:/certs:z \ -e "REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt" \ -e "REGISTRY_HTTP_TLS_KEY=/certs/domain.key" \ -e REGISTRY_COMPATIBILITY_SCHEMA1_ENABLED=true \ -d \ docker.io/library/registry:2.8.3
Trying to pull docker.io/library/registry:2.8.3... Getting image source signatures Copying blob 5daf2fb85fb9 done | Copying blob 68c26f40ad80 done | Copying blob 8f2a82336004 done | Copying blob ca5f23059090 done | Copying blob 619be1103602 done | Copying config 9363667f8a done | Writing manifest to image destination 304e2169d684ff81b5dd76f0de4a49035c73d1d7c70d59c4306feac5b66779be
registry Tags | Docker Hub で最新バージョンを確認できる🤔