建立私有 Docker Images Repository Server
===
* Docker 開發的 [registry](https://hub.docker.com/_/registry),是用來儲存、散布container images 的服務。
* [registry 已經捐贈](https://docs.docker.com/registry/?_gl=1*1wcvim0*_ga*MTE1NzgzMzM5MS4xNjk4ODM2ODE4*_ga_XJWPQMJYHQ*MTY5ODk5NTY4Mi41LjEuMTY5ODk5NTczMy45LjAuMA..)給 [CNCF](https://www.cncf.io/)
* 新的官網以及文件在 [Distribution Registry](https://distribution.github.io/distribution/)
* 你可以在以下網站取得
1. [Docker Hub](https://hub.docker.com/_/registry)
2. [Redhat Quay.io](https://quay.io/)
3. [Github](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry)
4. 各大雲端平台(AWS, Azure, Google Cloud, IBM Cloud)都可以找到
使用以下 Bash Shell Script 即可啟動 Repository
你也可以自行修改成 docker-compose.yml 檔案
```bash=
docker volume create reg_cfg_vol
docker volume create reg_data_vol
docker run -d -p 8080:5000 --restart=always \
--name repo \
-v reg_cfg_vol:/etc/docker/registry \
-v reg_data_vol:/var/lib/registry \
-e REGISTRY_COMPATIBILITY_SCHEMA1_ENABLED=true \
registry:latest
```
* registry Image Expose Port 是 5000
* 但 Docker Host 的 5000 Port 已被使用,所以 Docker Host Mapping Port 8080 到 Port 5000 (==請依自身環境調整==)
* docker push/pull 要使用 port 443 https
* 所以還要透過 Nginx Reverse Proxy 針對 {fqdn.domain.name} 網址,載入 SSL 憑證、轉址到 Port 8080
* 如果使用自簽憑證,或是不用 SSL,必須要設定每台 Docker Host Daemon "insecure-registries"
* 另外,設定 Nginx Reverse Proxy,比較重要的是設定 **client_max_body_size**,這個參數會影響 docker push 時,上傳的影像檔大小,超過這個 Size ,會無法 Push Image

Registry 的 API
---
1. 如何查看 Repo Server 上面有哪些 Images
https://{fqdn.domain.name}/v2/_catalog
2. 如何看特定 Image 的 Tag 版本
https://{fqdn.domain.name}/v2/{image_name}/tags/list
3. 下載特定版本 Image 的 manifests File
https://{fqdn.domain.name}/v2/{image_name}/manifests/{image_tag}
檔案中紀錄了:
- Schema 版本
- Image Name
- Image Tag
- Architecture 是 AMD64 還是 Windows
- Image 的 File System Layers 等資訊
參考資料
---
1. [Deploy a registry server](https://distribution.github.io/distribution/about/deploying/)
2. [Detail About Registry](https://distribution.github.io/distribution/about/)
3. [Registry HTTP API V2](https://distribution.github.io/distribution/spec/api/)
## 其他 Container Registry 軟體
* Harbor
* Gitlab Container Registry (Gitlab 內建,但需設定啟用)
* [Sonatype Nexus](https://www.sonatype.com/products/sonatype-nexus-repository)
* [Quay](https://www.projectquay.io/)
* [JFrog Artifactory Open Source](https://jfrog.com/community/download-artifactory-oss/)