---
# System prepended metadata

title: 使用 oc-mirror v2 下載 ocp image 到私有 registry

---

# 使用 oc-mirror v2 為離線環境下載 ocp image 至私有鏡倉庫

日期: 2025/12//24 ~ 2025/12/25
模擬情境: 企業環境有一台 Harbor server 可以透過 proxy 連到 redhat 相關 registry。想要把 ocp imgae 放到這個私有 Harbor 做離線環境的 ocp 安裝。

參考資料:
https://docs.redhat.com/en/documentation/openshift_container_platform/4.18/html/disconnected_environments/about-installing-oc-mirror-v2



## 1. 下載 pull secret (需登入 redhat 帳號)
https://console.redhat.com/openshift/install/metal/user-provisioned
![image](https://hackmd.io/_uploads/Bye2FDsQbl.png)


## 2. 下載 oc-mirror plugin，並上傳至 server (bastion、harbor本身都可以，反正那台機器可以連到你的私有鏡像倉庫)
https://console.redhat.com/openshift/downloads
![image](https://hackmd.io/_uploads/Hkl15voQ-x.png)


```bash=
tar xvzf oc-mirror.tar.gz
chmod +x oc-mirror
sudo mv oc-mirror /usr/local/bin/.
#驗證
oc mirror --v2 --help

mkdir -p /nfs/peter-ocp-mirror-test/ocp418
cd /nfs/peter-ocp-mirror-test/ocp418
```

## 3. pull secret 匯入主機
把第1步驟下載的pull secret 貼進來，並且加上 私有 rigistry 的驗證。
```bash=
#如果有先備份
cp /root/.docker/config.json /root/.docker/config.json.bak

cat pull-secret.txt | jq >  /root/.docker/config.json
podman login har.lab.com

cat /root/.docker/config.json
```
應該會有以下資訊:
:::info
/root/.dockerconfig.json
```json=
{
  "auths": {
    "cloud.openshift.com": {
"auth":"xxxxxxxxxx",
      "email":"xxxxxxxxxx@email.com"
    },
    "quay.io": {
"auth":"xxxxxxxxxx",
      "email":"xxxxxxxxxx@email.com"
    },
    "registry.connect.redhat.com": {
"auth":"xxxxxxxxxx",
      "email":"xxxxxxxxxx@email.com"
    },
    "registry.redhat.io": {
"auth":"xxxxxxxxxx",
      "email":"xxxxxxxxxx@email.com"
    }
  }
}
```
:::


## 4. 宣告 ImageSetConfiguration
```bash=
vim ImageSetConfiguration.yaml
```


:::info
ImageSetConfiguration.yaml
```yaml
kind: ImageSetConfiguration
apiVersion: mirror.openshift.io/v2alpha1
mirror:
  platform:
    channels:
    - name: stable-4.18
      minVersion: 4.18.27
      maxVersion: 4.18.27
```
:::

## 5. 執行 mirror
```bash=
cd /nfs/peter-ocp-mirror-test/ocp418
oc-mirror --v2 --cache-dir . -c ImageSetConfiguration.yaml file:///nfs/peter-ocp-mirror-test/ocp418/ 
```
:::danger
- `-cache-dir`: 很重要! 如果不指定 `cahce` 存放位置會預設會快取到 `${HOME}/.ocmirror/cahace/` 可能會把你的家目錄撐爆，造成 mirror 失敗。
:::

:::spoiler mirror log

```bash=
2025/12/24 17:52:07  [INFO]   : 👋 Hello, welcome to oc-mirror
2025/12/24 17:52:07  [INFO]   : ⚙️  setting up the environment for you...
2025/12/24 17:52:07  [INFO]   : ⚙️  environment version: 4.18.0-202510210939.p2.g0c70491.assembly.stream.el9-0c70491
2025/12/24 17:52:07  [INFO]   : 🔀 workflow mode: mirrorToDisk
2025/12/24 17:52:07  [INFO]   : 🕵  going to discover the necessary images...
2025/12/24 17:52:07  [INFO]   : 🔍 collecting release images...
2025/12/24 17:52:21  [INFO]   : 🔍 collecting operator images...
2025/12/24 17:52:21  [INFO]   : 🔍 collecting additional images...
2025/12/24 17:52:21  [INFO]   : 🔍 collecting helm images...
2025/12/24 17:52:21  [INFO]   : 🔂 rebuilding catalogs
2025/12/24 17:52:21  [INFO]   : 🚀 Start copying the images...
2025/12/24 17:52:21  [INFO]   : 📌 images to copy 189
 ✓   (10s) ocp-v4.0-art-dev@sha256:070c4c457c311a9bd4b04b1015d0d1ce289d7854921dee1266e27b06003e5951 ➡️  cache
 ✓   (10s) ocp-v4.0-art-dev@sha256:063bfc113ada350b0ea401ae3d4ef4c30d8f4c283e92d69f2fc3fc648e70114c ➡️  cache
 ✓   (10s) ocp-v4.0-art-dev@sha256:03c9565adbc95e1742cd22cd7ced4406dbaa377775e7a935b7ca891bb5232654 ➡️  cache
 ✓   (10s) ocp-v4.0-art-dev@sha256:0331005b926321624a48f4e38548eb2b83dd9eee3847cc8305f47278b18a77f3 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:076df6451aeb2e945904ce5fb7bb87727bcc578070cc3cb6ccaa48352bb6415b ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:0caf4e026b07fd8d5b6a910f55c6589622af72e2476b100212df9509d97a983f ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:0c921698d30c8175da0c124f72748e93551d6903b0f34d26743b60cb12d25cb1 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:079f411ffb5077d6498ca401cb650cb71f4298123cb16377640f1d4b88334a91 ➡️  cache
 ✓   (5s) ocp-v4.0-art-dev@sha256:123d95b0429fed7fd474dca636ce4d16b25663108269c56b8feb9490030f1147 ➡️  cache
 ✓   (8s) ocp-v4.0-art-dev@sha256:1347f08601c10d5876f71f23ac90f4f0a28a31134bd7177bba9665a7e107cdf1 ➡️  cache
 ✓   (6s) ocp-v4.0-art-dev@sha256:1be25c9c05a6e714c99239578a89ff6c2a2ed93a1e33add3a59899c7c8560031 ➡️  cache
 ✓   (10s) ocp-v4.0-art-dev@sha256:1d74291b1328340716a1740dbaf5abf18e8d1b19df0ca39d1a806db68a20292e ➡️  cache
 ✓   (18s) ocp-v4.0-art-dev@sha256:184239929f74bb7c56c1cf5b94b5f91dd4013a87034fe04b9fa1027d2bb6c5a4 ➡️  cache
 ✓   (7s) ocp-v4.0-art-dev@sha256:1da5bf06996d2f840c9fb3b80133f9d71646edc799dbcc990ffbefb8c8e950f0 ➡️  cache
 ✓   (19s) ocp-v4.0-art-dev@sha256:16011b29009d596478fc2521e7f36a27ba27910ce21e01f21ffb24b8b240f746 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:1fe86336a32e7f038fdd25b11a28f15fb4f8ecd83dc8a2464c17b38663986bda ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:1daf2cac50f146fbd0715456cdf04053b5dbb18c24bae51a4fd6b5ea9e27cb44 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:20a45eea23b06400b1b9e99a0f4e09757f94dd6ccfcdc8ab0ef33874e0725c5c ➡️  cache
 ✓   (10s) ocp-v4.0-art-dev@sha256:20510b2124ade39d5d1abc9fdee6e4c41818e35d8febaa67856cc47c5008f189 ➡️  cache
 ✓   (8s) ocp-v4.0-art-dev@sha256:23aa409d98c18a25b5dd3c14b4c5a88eba2c793d020f2deb3bafd58a2225c328 ➡️  cache
 ✓   (8s) ocp-v4.0-art-dev@sha256:233ae3955f307cbf463e2d728006d5f9ca89af5dbcf97b1f8384e3178efcf5d0 ➡️  cache
 ✓   (9s) ocp-v4.0-art-dev@sha256:22697aa8b9ecc72c7304f90ddba998c8336e60520e6770239a16700f2a00012b ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:24da82c00785cba7d60d1476e8e38ee3d0cc5a375a5638216db5ef27c9714e2b ➡️  cache
 ✓   (2s) ocp-v4.0-art-dev@sha256:2720ef973ad0a644921ea6bae30335f15024f8084702b40a49daeb282713edc4 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:257433a0e789418bfe7d813f52655709a6060076e91999852c49a58b7627182c ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:2795807194ae44710039d798099380157a0b37d678be0c7bf551215d8e1ebfc8 ➡️  cache
 ✓   (5s) ocp-v4.0-art-dev@sha256:2731364c4c533fe90d89aa9fd5412e9cefe163457f1d69c25bb5f44d7ec901cb ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:296462aa08198fa43aa0870287ed30733ebe3e1e9346a1b9a346c15406dcc3c5 ➡️  cache
 ✓   (6s) ocp-v4.0-art-dev@sha256:28b3ba29ff038781d3742df4ab05fac69a92cf2bf058c25487e47a2f4ff02627 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:2d41c3e944e86b73b4ba0d037ff016562211988f3206b9deb6cc7dccca708248 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:2ad82327a0c3eac3d7a73ca67630eaf63bafc37514ea75cb6e8b51e995458b01 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:2dc42ec15e3ecccc0942415ec68b27c2c10f53f084b6fa23caa1e81fc70f3629 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:2e254a7fb8a2643817718cfdb54bc819e86eb84232f6e2456548c55c5efb09d2 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:2f048f24f6d9c9afe07ab8d64c6aa12a1c3f2be718df791814ee844bafbca660 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:2f86d9ffe13cbab06ff676496b50a26bbc4819d8b81b98fbacca6aee9b56792f ➡️  cache
 ✓   (2s) ocp-v4.0-art-dev@sha256:3051af3343018fecbf3a6edacea69de841fc5211c09e7fb6a2499188dc979395 ➡️  cache
 ✓   (2s) ocp-v4.0-art-dev@sha256:31cb2cc8c79a9bbba50da05a41a61c39fab2421ce8735369f81410338e4be0e8 ➡️  cache
 ✓   (7s) ocp-v4.0-art-dev@sha256:36fa1378b9c26de6d45187b1e7352f3b1147109427fab3669b107d81fd967601 ➡️  cache
 ✓   (11s) ocp-v4.0-art-dev@sha256:3a1fbe783766a9a47d90265e08cdd962f4feaf1e8e0b111c2347956958cfe61b ➡️  cache
 ✓   (15s) ocp-v4.0-art-dev@sha256:39df823dbdd0fbefb4cf43ba5de717b97777eda40d2eeebe37d74f7d2d6cd314 ➡️  cache
 ✓   (16s) ocp-v4.0-art-dev@sha256:37c9ba257d23940e758f55b6cf6a154a04210a5eaaf1586c252736de52833519 ➡️  cache
 ✓   (18s) ocp-v4.0-art-dev@sha256:36edacc5167d38c00fd6fb0150d5f91535ac8b7e43c218ef275032d5178859bd ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:3cc3977d34490059b692d5fbdb89bb9a676db39c88faa35f5d9b4e98f6b0c4e2 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:3a2ef63f356c11ba629d8038474ab287797340de1219b4fee97c386975689110 ➡️  cache
 ✓   (5s) ocp-v4.0-art-dev@sha256:3d835ce07d1bec4a4b13f0bca5ea20ea5c781ea7853d7b42310f4ad8aeba6d7c ➡️  cache
 ✓   (8s) ocp-v4.0-art-dev@sha256:3ef6fd8a728768571ca93950ec6d7222c9304a98d81b58329eeb7974fa2c8dc8 ➡️  cache
 ✓   (11s) ocp-v4.0-art-dev@sha256:3ed4dc45b0e0d6229620e2ac6a53ecd180cad44a11daf9f0170d94b4acd35ded ➡️  cache
 ✓   (23s) ocp-v4.0-art-dev@sha256:3f45a045dc2269d1f88310b741629e65c832aa7e16cc2c4506ef81c392e86400 ➡️  cache
 ✓   (25s) ocp-v4.0-art-dev@sha256:3f0f1a97fe1de0c82f6b4472db7a1a473cdedcb91e33b9583417d3d05e760a80 ➡️  cache
 ✓   (36s) ocp-v4.0-art-dev@sha256:3d886210d2faa9ace5750adfc70c0c3c5512cdf492f19d1c536a446db659aabb ➡️  cache
 ✓   (40s) ocp-v4.0-art-dev@sha256:3b8b3feb3da957209e7e6af7e08ffceb314c0614b2298531cfc00035c6c4a9db ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:434808b43343f6f381cd94c85bcb61ce9b58f79bcb12f77bad9e315f408adf41 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:40b57bf299fad7c519be21de7f142fa6d08130d0b3b4e53118c1ca2e162f519b ➡️  cache
 ✓   (5s) ocp-v4.0-art-dev@sha256:42285ecbf77c9f1076eba932787de7f8ae851e832aa81d5b7261034d62e469c6 ➡️  cache
 ✓   (5s) ocp-v4.0-art-dev@sha256:43ada42bcacdadf74bfe627c6ddcc822ec803874065298175ccff3c0f45f0f71 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:44e82a51fce7b5996b183c10c44bd79b0e1ae2257fd5809345fbca1c50aaa08f ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:43f2cdef40e40da7407a6e2e0c4b5057ba891fc0518764cce1c4c6850febc119 ➡️  cache 
 ✓   (7s) ocp-v4.0-art-dev@sha256:47bf3706e0f5a40f46467e08e3bf9c8280d5425db2a34502f8168d6d05e053f8 ➡️  cache
 ✓   (26s) ocp-v4.0-art-dev@sha256:479b03afc1e09e59eda7e92491f6f679e3c8215f66d18ea5b4e536d6fff17439 ➡️  cache
 ✓   (23s) ocp-v4.0-art-dev@sha256:47beaa950d9e235ec7200f1e9363b001704babe37ad9727a84d8578910f41426 ➡️  cache
 ✓   (16s) ocp-v4.0-art-dev@sha256:492103a8365ef9a1d5f237b4ba90aff87369167ec91db29ff0251ba5aab2b419 ➡️  cache
 ✓   (27s) ocp-v4.0-art-dev@sha256:4686140ac85b1755e477c5821f5a27a297ac4a02bae32c246a91d506e24125f8 ➡️  cache
 ✓   (2s) ocp-v4.0-art-dev@sha256:4a3e2790bda8898df5e4e9cf1878103ac483ea1633819d76ea68976b0b2062b6 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:49fe08891e44cb5d06436fd7c36c8fbbeb3eefe29c3ecbc09b98e21879cb60eb ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:4b3e27877a3cfb218ce3a7a5163748ca4f3cd6c77774180c8824364498347763 ➡️  cache
 ✓   (7s) ocp-v4.0-art-dev@sha256:4bb7973c609c19a4195a61de54624bc6f436b05a819067353ac1cb219356e636 ➡️  cache
 ✓   (5s) ocp-v4.0-art-dev@sha256:51a4c20765f54b6a6b5513f97cf54bb99631c2abe860949293456886a74f87fe ➡️  cache
 ✓   (12s) ocp-v4.0-art-dev@sha256:4cb6ecfb89e53653b69ae494ebc940b9fcf7b7db317b156e186435cc541589d9 ➡️  cache
 ✓   (15s) ocp-v4.0-art-dev@sha256:4bb22a677842f859f0fed568e4a5d8cc2802b71ac69868e418e567f526acb4fe ➡️  cache
 ✓   (13s) ocp-v4.0-art-dev@sha256:4eb6df56d2857e650486d41c5e264e77cecd4f5797c7e2aa209cd38cee5b4a0d ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:5290b1843af439026c166e308f178a2b8963aa360c52ed874e4419b5c5864f92 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:5b6cfb0f9dcbef6fb2d7828e4ed3449ac9aa05aa06061863ab3a7f4f809891fd ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:58ed827ee19ac91b6f860d307797b24b8aec02e671605388c4afe4fa19ddfc36 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:5ee6d947dc4ca8b2e2077aee59d37b4fb7f6038d20233b0b6c2b410be4727a81 ➡️  cache
 ✓   (6s) ocp-v4.0-art-dev@sha256:60b204272b95861b1586b90f20ab94f9c9de5620b1e073fa0cad47e3a48556c7 ➡️  cache
 ✓   (10s) ocp-v4.0-art-dev@sha256:613e0e8ab8709b79ea2c9f5b18fd89299aa447e175c2efe00be6d0ce5f84da0a ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:6363cc3335d2a930fa0e4e6c6c3515fa0ef85e9d7abb3b3007fbb185eabb498f ➡️  cache
 ✓   (9s) ocp-v4.0-art-dev@sha256:62de813f3c56440536a2b1c89edc66817a5c9460eab8e6913acb775540133fb1 ➡️  cache
 ✓   (10s) ocp-v4.0-art-dev@sha256:6199be91b821875ba2609cf7fa886b74b9a8b573622fe33cc1bc39cd55acac08 ➡️  cache
 ✓   (11s) ocp-v4.0-art-dev@sha256:656fe650bac2929182cd0cf7d7e566d089f69e06541b8329c6d40b89346c03ca ➡️  cache
 ✓   (12s) ocp-v4.0-art-dev@sha256:64a0ada34535f28adcd8a6211711cc23975d33e63aa5090a352619402c44af5a ➡️  cache
 ✓   (12s) ocp-v4.0-art-dev@sha256:65e52a0fe18c5f9a82198381fb3b63eebad2e71f96216950f22f1b4caf887e58 ➡️  cache
 ✓   (13s) ocp-v4.0-art-dev@sha256:6435ccf44034d6236bd1ecbf1d920243c0e9c353a28b36d8a7ad69ec5a16baaa ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:673d82432b385aa67a891139b7945a504b7dff8d9a7c933d538fd1b7701e23db ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:68dbccdff76515d5b659c9c2d031235073d292cb56a5385f8e69d24ac5f48b8f ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:680fd6619cdc308cfa11d969dd39f1fcabb5596895c063688512656e23dbf355 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:68927631ebab9644417c35986e6cfdd9aea8570530d056f72249cbc485cc05fa ➡️  cache
 ✓   (5s) ocp-v4.0-art-dev@sha256:6de9992f019bdf4316a8feaffdcc6200fb4dd70ec76b93c7dac4a17e4de190fd ➡️  cache
 ✓   (5s) ocp-v4.0-art-dev@sha256:6dd80564094a262c1bb53c037288c9c69a46b22dc7dd3ee5c52384404ebfdc81 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:6ed83a45f46d58c73c981f8d59fbe1f00f5039d7ed32f17a95120d5cfaa905da ➡️  cache
 ✓   (5s) ocp-v4.0-art-dev@sha256:6ca7383e77955195448f5ce279683fd53e2295ccfd2c269d1bfe53f9b9b3c811 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:70433dff5951c3a0964b92bee9ae682bd5370323c9fce5be904ace1a69deeff4 ➡️  cache
 ✓   (5s) ocp-v4.0-art-dev@sha256:77d6fa15964fce99006d03f74ba49cdb25cece21d9fc35f8bdee8244e702d1c0 ➡️  cache
 ✓   (5s) ocp-v4.0-art-dev@sha256:7347193795ceafb41bcf6f6471f8e8975c4f8f9e55b15dfe1f3a731077188ff1 ➡️  cache
 ✓   (6s) ocp-v4.0-art-dev@sha256:708d42070d02267c62f104e616292a4935c76bb153bcdd6a0e0ea67504b78263 ➡️  cache
 ✓   (2s) ocp-v4.0-art-dev@sha256:7825952834ade266ce08d1a9eb0665e4661dea0a40647d3e1de2cf6266665e9d ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:78f6aebe76fa9da71b631ceced1ed159d8b60a6fa8e0325fd098c7b029039e89 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:79552047f41bfeae58048c7637801d43c87aff1778abf47b9f93453835a8c7fa ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:783d0599baf25a5139db4363206642192240e8c3e377b983ebe1cdb52c520ab4 ➡️  cache
 ✓   (6s) ocp-v4.0-art-dev@sha256:79bc5d171f1878f0a76de12cb82cdd6685bcfc0804a8f5d064c63f1650e88a23 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:7f656ff66f14895a1910ef7d0eb39c6f6f66f009c5cffbd5b3e53aa97090b638 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:84a52132860e74998981b76c08d38543561197c3da77836c670fa8e394c5ec17 ➡️  cache
 ✓   (8s) ocp-v4.0-art-dev@sha256:86258f84119d2ddb476143b4667bf6c0edb1f04ac61cfb76fbd6978e65b19e54 ➡️  cache
 ✓   (10s) ocp-v4.0-art-dev@sha256:7fc49790ff76c95e0af58afff1b412ca913fb4a9cfdac98f8aa66aeba50df4c8 ➡️  cache
 ✓   (7s) ocp-v4.0-art-dev@sha256:89b279931fe13f3b33c9dd6cdf0f5e7fc3e5384b944f998034d35af7242a47fa ➡️  cache
 ✓   (7s) ocp-v4.0-art-dev@sha256:88baddb3011dcf938aab114136eecab4dafa1e4793be2eab369d2c8744747b4c ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:8a39e266e11acd6079d09b8a05033b746797008c0b0a49757868feaecdeab480 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:8d8855420e61180109ab150548daa356d20f7aa31bc26744800eaba0f7abe027 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:8e8903affdf29401b9a86b9f58795c9f445f34194960c7b2734f30601c48cbdf ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:8df78826ffbf29ea291cde12a4eb81b8d63103ddb15b01c5af55d22e80448989 ➡️  cache
 ✓   (2s) ocp-v4.0-art-dev@sha256:903557bdbb44cf720481cc9b305a8060f327435d303c95e710b92669ff43d055 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:8f779b92bb88fcd240c4f99de4b186847e5723335919e3d2557b7b0aa3743543 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:93444064d1707591de4607207e0d89d8eef417e0981fc6a30c7b7681c3e0b615 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:93145fd0c004dc4fca21435a32c7e55e962f321aff260d702f387cfdebee92a5 ➡️  cache
 ✓   (2s) ocp-v4.0-art-dev@sha256:960d783c6edb80eb9afe52b0fc4f7b44fd0f28dc54fa3801395c18780ba6a524 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:9623383df0f01ec565daeefc81932ffcd513dd29f48f7a9c7dd38e79ec5f5b01 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:9877ca1ba3efa3cd9adef41dc8c4f080601879457e852fc20498f176e54d38b9 ➡️  cache
 ✓   (10s) ocp-v4.0-art-dev@sha256:99327fbbfc29d31a82ff628e6bbdb75be36509956e43694de191c4a0a30aa1bc ➡️  cache
 ✓   (10s) ocp-v4.0-art-dev@sha256:9a045e84becd62c12b1c0ba59ebb9f643ebe3eea869742a60928e96ef55063cb ➡️  cache
 ✓   (13s) ocp-v4.0-art-dev@sha256:98ce2d349f8bc693d76d9a68097b758b987cf17ea3beb66bbd09d12fa78b4d0c ➡️  cache
 ✓   (12s) ocp-v4.0-art-dev@sha256:9d1d33147bc8b08d7371025f4db558fea34d36f55f423b4cf25392483a93331b ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:a2c8408dc6016a4df95d0e4ae7fc8e3cd580a478cce52c18ecd44b4b16993abd ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:a01bde662d749691118d69f00c4bd0d7f5fe075fa3cd25b90b240ab240200cc6 ➡️  cache
 ✓   (6s) ocp-v4.0-art-dev@sha256:9f4724570795357eb097251a021f20c94c79b3054f3adb3bc0812143ba791dc1 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:a5a68ca2de637b37480aea76d2e5637d5ffdb13dd69b9e7a82fd47b0736b22a8 ➡️  cache
 ✓   (10s) ocp-v4.0-art-dev@sha256:ae62948bab2f104c540a5c7ee1e3e8ba119496e05089c90acddbd32291dba1f9 ➡️  cache
 ✓   (11s) ocp-v4.0-art-dev@sha256:a5cee8a1e202afa47fd05893aa13dded796813c9f1002a530c785628f32ca02c ➡️  cache
 ✓   (11s) ocp-v4.0-art-dev@sha256:a6a8017b89bfef4a76f8523a9e89288c664475a4060eeb37c09c3cf711b55f60 ➡️  cache
 ✓   (8s) ocp-v4.0-art-dev@sha256:ae8c6193ace2c439dd93d8129f68f3704727650851a628c906bff9290940ef03 ➡️  cache
 ✓   (2s) ocp-v4.0-art-dev@sha256:b0737727dcbfb50c3c09b69684ba3c07b5a4ab7652bbe4970a46d6a11c4a2bca ➡️  cache
 ✓   (2s) ocp-v4.0-art-dev@sha256:b03d2897e7cc0e8d0c306acb68ca3d9396d502882c14942faadfdb16bc40e17d ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:b1f1f1015a17aeaacbc451eb64009bf387506b64dec4ebe8d013c1ec3d24e638 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:b66bbf093cd69de010fb9a293701ec313dbe04c9122ee0784e0c27303c9d3dd2 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:b7b10c78ffd29bee19d9249a2b5528612a197008dce2ecc146903fab40c9b946 ➡️  cache
 ✓   (19s) ocp-v4.0-art-dev@sha256:bb22cccf0a0b66f76ac87d1294d223bfa207262e4bdd7bac15df792e015dbc6b ➡️  cache
 ✓   (21s) ocp-v4.0-art-dev@sha256:baef24f68fe77352ca646048bfc0e1c5c1367540c5eab5ba97533ca428ae0a74 ➡️  cache
 ✓   (23s) ocp-v4.0-art-dev@sha256:b9e597b928c0bdcdebea19f093353a7ada98f5164601abf23aa97f0065c6e293 ➡️  cache
 ✓   (21s) ocp-v4.0-art-dev@sha256:b9f3dfbe2e3362b963e3f8784cac8fd0bda1c23a0fee80784a7e3dedf3a8bf7c ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:c1c5077f796820d78d6fee5edaeb08d465c1d3e8ad1f2809ba3021e38581b49c ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:c164f4151b3081c4fca16a7ea6dca8dd71555e9428757a8de0f8ae471846cd22 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:c2b518cb834a0b6ca50d73eceb5f8e64aefb09094d39e4ba0d8e4632f6cdf908 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:bbe8bb4acfac2880787b6a4b73ce2c51b1741160e46f5ba5a291d9cc959d325c ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:c2b8949f37f2f46e316cb62da6e3a028d3d43221be15dc28c3ead5c85dcc4d4c ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:c670073451b8559ce457edc116f4f8399f815cae604d3dba0a3caaefc0ed6552 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:c8fd694cf54d027e2220a228db6df46655bd880ba3e7654e2277fc1efb22ab5d ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:c8364e272411f8159cba4cd5484776868c9d7bc8f0046a203bd35ac6be84c0bc ➡️  cache
 ✓   (5s) ocp-v4.0-art-dev@sha256:c9562b1bb57e930328da4ae9591c4af1f235b77c036f027efd6ab7c713c2e395 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:ca6cf701f5ccbc6511820a531711bf7ed02ad10a5093ad124b558b336a9543b9 ➡️  cache
 ✓   (5s) ocp-v4.0-art-dev@sha256:ca4933b9ba55069205ea53970128c4e8c4b46560ef721c8aaee00aaf736664b5 ➡️  cache
 ✓   (5s) ocp-v4.0-art-dev@sha256:ca110492e70a629b9a4ec26bc27d967c36ad0b7c642d9bd325bae1dee552fbed ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:ceaa4102b35e54be54e23c8ea73bb0dac4978cffb54105ad00b51393f47595da ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:d0f12071e194db36edf1326b93818088cd2e92a4b02b93ba4c273569be5dc8cd ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:d0c6de747539dd00ede882fb4f73cead462bf0a7efda7173fd5d443ef7a00251 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:d12d87386ab9c19148c49c1e79d839a6f47f3a2cd7e078d94319d80b6936be13 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:d3563994c8c733b9419a6fbe81b57d4c97f1860bab5b92e7c1b000f76e510a71 ➡️  cache
 ✓   (6s) ocp-v4.0-art-dev@sha256:d4b7877d8d082a2b844ad8b3a7a440976f79820693db91e6392b93b9ee50526c ➡️  cache
 ✓   (15s) ocp-v4.0-art-dev@sha256:d3c0962dbbad51633a7d97ef253d0249269bfe3bbef3bfe99a99457470e7a682 ➡️  cache
 ✓   (13s) ocp-v4.0-art-dev@sha256:d5d6b4899a6ed1f4406a85a2289d561e04975dbb1f0c765c355715337aba152b ➡️  cache
 ✓   (10s) ocp-v4.0-art-dev@sha256:d8c6475baffce6aab773b7a79c4639f6eb50f3b9db999812c9c814c817496ac3 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:da8bd3ec0d2544bfd7e650f3611a4f16885ac0b7b39700ecdaa92792dc7c90b4 ➡️  cache
 ✓   (9s) ocp-v4.0-art-dev@sha256:da6f62afd2795d1b0af69532a5534c099bbb81d4e7abd2616b374db191552c51 ➡️  cache
 ✓   (7s) ocp-v4.0-art-dev@sha256:dc72da7f7930eb09abf6f8dbe577bb537e3a2a59dc0e14a4319b42c0212218d1 ➡️  cache
 ✓   (9s) ocp-v4.0-art-dev@sha256:dc9758be9f0f0a480fb5e119ecb1e1101ef807bdc765a155212a8188d79b9e60 ➡️  cache
 ✓   (30s) ocp-v4.0-art-dev@sha256:d3a1c1e1ca85f95011f0da66c04a1bbab66920684213d0f5d58865442b09bc04 ➡️  cache
 ✓   (17s) ocp-v4.0-art-dev@sha256:debbfa579e627e291b629851278c9e608e080a1642a6e676d023f218252a3ed0 ➡️  cache
 ✓   (17s) ocp-v4.0-art-dev@sha256:df5101ff9d010c948f5233737fa58ee286ef8731756d0c0a062b259aa148fa47 ➡️  cache
 ✓   (12s) ocp-v4.0-art-dev@sha256:dfd890f575e681dcb3ea5445462f47ef15d90e48dd0da483f02f62d547c973b8 ➡️  cache
 ✓   (15s) ocp-v4.0-art-dev@sha256:dfc0403f71f7c926db1084c7fb5fb4f19007271213ee34f6f3d3eecdbe817d6b ➡️  cache
 ✓   (2s) ocp-v4.0-art-dev@sha256:e39fd49a8aa33e4b750267b4e773492b85c08cc7830cd7b22e64a92bcb5b6729 ➡️  cache
 ✓   (5s) ocp-v4.0-art-dev@sha256:e170472776049ecfc4867f6f37fa0a246831043e380dc74d00e3a13a91f2db77 ➡️  cache
 ✓   (7s) ocp-v4.0-art-dev@sha256:e074371f27c58f876444193f800b1d6413b9e8bf44a17bd47c46a4e009ceb529 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:eac937aae64688cb47b38ad2cbba5aa7e6d41c691df1f3ca4ff81e5117084d1e ➡️  cache
 ✓   (7s) ocp-v4.0-art-dev@sha256:e50a270ad04d1e8d864d7cffc3ba3f3ca5d7111ba09ac4b234f4386c3da53576 ➡️  cache
 ✓   (7s) ocp-v4.0-art-dev@sha256:e8f313372fe49afad871cc56225dcd4d31bed249abeab55fb288e1f854138fbf ➡️  cache
 ✓   (5s) ocp-v4.0-art-dev@sha256:e955ac7de27deecd1a88d06c08a1b7a43e867cadf4289f20a6ab982fa647e6b7 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:ee896bce586a3fcd37b4be8165cf1b4a83e88b5d47667de10475ec43e31b7926 ➡️  cache
 ✓   (3s) ocp-v4.0-art-dev@sha256:ebd79294a663cb38370ae81f9cda91cef7fb1370ec5b495b4bdb95e77272e6a8 ➡️  cache
 ✓   (4s) ocp-v4.0-art-dev@sha256:eefdc67602b8bc3941001b030ab95d82e10432f814634b80eb8ce45bc9ebd3de ➡️  cache                                                                                                                    
 ✓   (7s) ocp-v4.0-art-dev@sha256:efcc297b635136f17fa8071c1ca2ed49319b40e980c1d94a1ec922a5f1ca90b2 ➡️  cache
 ✓   (7s) ocp-v4.0-art-dev@sha256:ef51f50a9bf1b4dfa6fdb7b484eae9e3126e813b48f380c833dd7eaf4e55853e ➡️  cache
 ✓   (12s) ocp-v4.0-art-dev@sha256:ecb123a49fe36f5975c2684e1a063ded0e3c7ce8ebaa6ad5d76922cb9bd41bcd ➡️  cache
 ✓   (11s) ocp-v4.0-art-dev@sha256:f303cafa5482c132a29f912051b0f8aeebd2f35f765b4b5b7ae9b8e68ce62ee6 ➡️  cache
 ✓   (8s) ocp-v4.0-art-dev@sha256:f870aa3c7bcd039c7905b2c7a9e9c0776d76ed4cf34ccbef872ae7ad8cf2157f ➡️  cache
 ✓   (19s) ocp-v4.0-art-dev@sha256:f734c5d3db3668f61428823e244090b59c35b1165269284981607f1e74cd6478 ➡️  cache
 ✓   (13s) ocp-v4.0-art-dev@sha256:ff8a5f36a6ed22d1d37e936d78c742dfafebe2910bdd3ab44c5ba0148d3199c4 ➡️  cache
 ✓   (2s) ocp-release:4.18.27-x86_64 ➡️  cache
 ✓   (26s) ocp-v4.0-art-dev@sha256:faba2837dc58c837289c79cd2c2e9e4c6185f7273f88c0b44cc6b30b17957bb6 ➡️  cache
 ✓   (41s) ocp-v4.0-art-dev@sha256:f8a38d71a75c4fa803249cc709d60039d14878e218afd88a86083526ee8f78ad ➡️  cache
189 / 189 (6m57s) [======================================================================================================================================================================================================] 100 %
 ✓   (27s) ocp-v4.0-art-dev@sha256:ff94e909d3b037c815e8ae67989a7616936e67195b758abac6b5d3f0d59562c8 ➡️  cache
2025/12/24 17:59:18  [INFO]   : === Results ===
2025/12/24 17:59:18  [INFO]   :  ✓  189 / 189 release images mirrored successfully
2025/12/24 17:59:18  [INFO]   : 📦 Preparing the tarball archive...
2025/12/24 18:03:21  [INFO]   : mirror time     : 11m13.94604859s
2025/12/24 18:03:21  [INFO]   : 👋 Goodbye, thank you for using oc-mirror
```
:::


## 6 建立 harbor project
項目 > 新建項目 > 輸入項目名稱 > 確定
![image](https://hackmd.io/_uploads/r1qhxot7Wx.png)

## 7.將 image tar 檔 mirror 至私有鏡像倉庫
```bash=
podman login har.lab.com

oc-mirror --v2 \
--cache-dir . \
-c ./ImageSetConfiguration.yaml \
--from file:///nfs/peter-ocp-mirror-test/ocp418/ \
docker://har.lab.com/peter-ocp-mirror-test
```
- `--from`: v2 版的只能指定目錄，該目錄底下的 `.tar` 檔都會被推送至私有鏡像倉庫。
:::spoiler mirror log
```bash=
oc-mirror --v2 --cache-dir . -c ./ImageSetConfiguration.yaml --from file:///nfs/peter-ocp-mirror-test/ocp418/ docker://har.lab.com/peter-ocp-mirror-test

2025/12/25 01:00:40  [INFO]   : 👋 Hello, welcome to oc-mirror
2025/12/25 01:00:40  [INFO]   : ⚙️  setting up the environment for you...
2025/12/25 01:00:40  [INFO]   : ⚙️  environment version: 4.18.0-202510210939.p2.g0c70491.assembly.stream.el9-0c70491
2025/12/25 01:00:40  [INFO]   : 🔀 workflow mode: diskToMirror
2025/12/25 01:00:40  [INFO]   : 📦 Extracting mirror archive(s)...
/nfs/peter-ocp-mirror-test/ocp418/mirror_000001.tar (20.0 GiB / 20.0 GiB) [=================================================================] 4m37s
2025/12/25 01:05:17  [INFO]   : 🕵  going to discover the necessary images...
2025/12/25 01:05:17  [INFO]   : 🔍 collecting release images...
2025/12/25 01:05:17  [INFO]   : 🔍 collecting operator images...
2025/12/25 01:05:17  [INFO]   : 🔍 collecting additional images...
2025/12/25 01:05:17  [INFO]   : 🔍 collecting helm images...
2025/12/25 01:05:17  [INFO]   : 🚀 Start copying the images...
2025/12/25 01:05:17  [INFO]   : 📌 images to copy 189
(0s) ocp-v4.0-art-dev@sha256:0331005b926321624a48f4e38548eb2b83dd9eee3847cc8305f47278b18a77f3 ➡️  har.lab.com/peter-ocp-mirror-test/opee…
(0s) ocp-v4.0-art-dev@sha256:03c9565adbc95e1742cd22cd7ced4406dbaa377775e7a935b7ca891bb5232654 ➡️  har.lab.com/peter-ocp-mirror-test/opee…
(0s) ocp-v4.0-art-dev@sha256:0331005b926321624a48f4e38548eb2b83dd9eee3847cc8305f47278b18a77f3 ➡️  har.lab.com/peter-ocp-mirror-test/ope…
(0s) ocp-v4.0-art-dev@sha256:03c9565adbc95e1742cd22cd7ced4406dbaa377775e7a935b7ca891bb5232654 ➡️  har.lab.com/peter-ocp-mirror-test/ope…
...
...
(省略)
...
...
 ✓ (0s) ocp-v4.0-art-dev@sha256:f870aa3c7bcd039c7905b2c7a9e9c0776d76ed4cf34ccbef872ae7ad8cf2157f ➡️  har.lab.com/peter-ocp-mir…
 ✓ (0s) ocp-v4.0-art-dev@sha256:faba2837dc58c837289c79cd2c2e9e4c6185f7273f88c0b44cc6b30b17957bb6 ➡️  har.lab.com/peter-ocp-mir…
189 / 189 (23s) [===========================================================================================================================] 100 %
 ✓   (0s) ocp-release:4.18.27-x86_64 ➡️  har.lab.com/peter-ocp-mirror-test/openshift/
 ✓ (0s) ocp-v4.0-art-dev@sha256:ff94e909d3b037c815e8ae67989a7616936e67195b758abac6b5d3f0d59562c8 ➡️  har.lab.com/peter-ocp-mir…
 ✓ (0s) ocp-v4.0-art-dev@sha256:ff8a5f36a6ed22d1d37e936d78c742dfafebe2910bdd3ab44c5ba0148d3199c4 ➡️  har.lab.com/peter-ocp-mir…
2025/12/25 01:05:41  [INFO]   : === Results ===
2025/12/25 01:05:41  [INFO]   :  ✓  189 / 189 release images mirrored successfully
2025/12/25 01:05:41  [INFO]   : 📄 Generating IDMS file...
2025/12/25 01:05:41  [INFO]   : /nfs/peter-ocp-mirror-test/ocp418/working-dir/cluster-resources/idms-oc-mirror.yaml file created
2025/12/25 01:05:41  [INFO]   : 📄 Generating ITMS file...
2025/12/25 01:05:41  [INFO]   : /nfs/peter-ocp-mirror-test/ocp418/working-dir/cluster-resources/itms-oc-mirror.yaml file created
2025/12/25 01:05:41  [INFO]   : 📄 No catalogs mirrored. Skipping CatalogSource file generation.
2025/12/25 01:05:41  [INFO]   : 📄 No catalogs mirrored. Skipping ClusterCatalog file generation.
2025/12/25 01:05:41  [INFO]   : 📄 Generating Signature Configmap...
2025/12/25 01:05:41  [INFO]   : /nfs/peter-ocp-mirror-test/ocp418/working-dir/cluster-resources/signature-configmap.json file created
2025/12/25 01:05:41  [INFO]   : /nfs/peter-ocp-mirror-test/ocp418/working-dir/cluster-resources/signature-configmap.yaml file created
2025/12/25 01:05:41  [INFO]   : mirror time     : 5m0.998520682s
2025/12/25 01:05:41  [INFO]   : 👋 Goodbye, thank you for using oc-mirror
```
:::

上傳完成!
![image](https://hackmd.io/_uploads/SJJJZoKXbg.png)
