差異處
這裏顯示兩個版本的差異處。
| 兩邊的前次修訂版 前次修改 下次修改 | 前次修改 | ||
| tech:dockerhubproxy [2025/06/09 13:55] – 增加 Gemini 2.5Pro 提供方案 jonathan | tech:dockerhubproxy [2025/06/24 12:33] (目前版本) – [registry:2 方案(適合小型服務情境)] jonathan | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | ====== | + | ====== 建立與設定 DockerHub Proxy ====== |
| * 因為 [[https:// | * 因為 [[https:// | ||
| + | ===== registry:2 方案(適合小型服務情境) ===== | ||
| + | - 檔案配置結構 <cli> | ||
| + | . | ||
| + | ├── cleanup.sh | ||
| + | ├── config | ||
| + | │ | ||
| + | ├── data | ||
| + | ├── .env | ||
| + | └─── docker-compose.yml | ||
| + | </ | ||
| + | - 產生 REGISTRY_HTTP_SECRET <cli> | ||
| + | dockerhub-184: | ||
| + | 005311c1d394ec958d6e1966bf43b4d3 | ||
| + | </ | ||
| + | - 建立 .env 環境變數設定< | ||
| + | vi .env</ | ||
| + | - 建立 cleanup.sh <cli> | ||
| + | vi cleanup.sh</ | ||
| + | - 建立 config.yml <cli> | ||
| + | mkdir -p config | ||
| + | vi config/ | ||
| + | - 建立 image 存放路徑 <cli> | ||
| + | mkdir -p data | ||
| + | </ | ||
| + | - 建立 docker-compose.yml <cli> | ||
| + | vi docker-compose.yml</ | ||
| + | - 啟動服務與查看 log <cli> | ||
| + | docker compose up -d | ||
| + | docker compose logs -f | ||
| + | </ | ||
| + | - 測試服務 <cli> | ||
| + | curl -I http:// | ||
| + | </ | ||
| + | * 應該可以看到類似以下的訊息< | ||
| + | dockerhub-184: | ||
| + | HTTP/1.1 200 OK | ||
| + | Content-Length: | ||
| + | Content-Type: | ||
| + | Docker-Distribution-Api-Version: | ||
| + | X-Content-Type-Options: | ||
| + | Date: Mon, 09 Jun 2025 09:43:05 GMT | ||
| + | </ | ||
| + | - 其他測試服務命令 <cli> | ||
| + | # 查看目前緩存的 repositories | ||
| + | curl -X GET http:// | ||
| + | |||
| + | # 手動執行清理腳本 | ||
| + | docker exec registry_cleaner /cleanup.sh | ||
| + | </ | ||
| + | |||
| + | ==== 其他主機設定 / | ||
| + | * Exp. registry:2 服務安裝在 192.168.11.184 | ||
| + | - 編輯 / | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | ], | ||
| + | " | ||
| + | " | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | - 重啟 docker < | ||
| + | - 確認設定是否生效< | ||
| + | * ++看執行內容是否出現 http:// | ||
| + | tools-185: | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | ] | ||
| + | } | ||
| + | tools-185: | ||
| + | * Stopping Docker Daemon ... [ ok ] | ||
| + | * Starting Docker Daemon ... [ ok ] | ||
| + | tools-185: | ||
| + | Client: | ||
| + | | ||
| + | | ||
| + | Debug Mode: false | ||
| + | | ||
| + | buildx: Docker Buildx (Docker Inc.) | ||
| + | Version: | ||
| + | Path: / | ||
| + | compose: Docker Compose (Docker Inc.) | ||
| + | Version: | ||
| + | Path: / | ||
| + | |||
| + | Server: | ||
| + | | ||
| + | Running: 0 | ||
| + | Paused: 0 | ||
| + | Stopped: 1 | ||
| + | | ||
| + | | ||
| + | | ||
| + | Backing Filesystem: extfs | ||
| + | Supports d_type: true | ||
| + | Using metacopy: false | ||
| + | Native Overlay Diff: true | ||
| + | userxattr: false | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | Volume: local | ||
| + | Network: bridge host ipvlan macvlan null overlay | ||
| + | Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog | ||
| + | | ||
| + | | ||
| + | | ||
| + | Init Binary: docker-init | ||
| + | | ||
| + | runc version: 7cb363254b69e10320360b63fb73e0ffb5da7bf2 | ||
| + | init version: | ||
| + | | ||
| + | seccomp | ||
| + | | ||
| + | cgroupns | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | CPUs: 1 | ||
| + | Total Memory: 966.3MiB | ||
| + | Name: tools-185 | ||
| + | ID: 9b3d9430-53d6-4024-a50f-865f0886a474 | ||
| + | | ||
| + | Debug Mode: false | ||
| + | | ||
| + | | ||
| + | 127.0.0.0/8 | ||
| + | | ||
| + | http:// | ||
| + | Live Restore Enabled: false | ||
| + | |||
| + | WARNING: bridge-nf-call-iptables is disabled | ||
| + | WARNING: bridge-nf-call-ip6tables is disabled | ||
| + | tools-185: | ||
| + | </ | ||
| + | - 執行 docker pull 驗證< | ||
| + | docker pull alpine | ||
| + | </ | ||
| + | - 如果成功 pull image, 可以回到 registry:2 服務主機 Exp. 192.168.11.184 查看 data/ | ||
| + | * ++看 tree data/ | ||
| + | dockerhub-184: | ||
| + | data/ | ||
| + | ├── library | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | └── owntracks | ||
| + | └── recorder | ||
| + | ├── _layers | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | ├── _manifests | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | └── _uploads | ||
| + | |||
| + | 39 directories, | ||
| + | dockerhub-184: | ||
| + | </ | ||
| + | |||
| + | ===== Harbor 方案(適合大型服務情境) ===== | ||
| + | * 先參考 [[harbor_docker]] 建立 Harbor 服務 | ||
| + | * 在 系統管理 -> Registry管理 -> 新增端點 Exp. dockerhub | ||
| + | * 提供者 : Docker Hub | ||
| + | * 端點名稱 : dockerhub | ||
| + | * 端點 URL : https:// | ||
| + | * 點 **測試連線** 如果正常就可以 **儲存** \\ {{: | ||
| ===== 參考網址 ===== | ===== 參考網址 ===== | ||