- 取得連結
- X
- 以電子郵件傳送
- 其他應用程式
Docker 官方文件建議私有的 Docker Registry 使用 TLS 協定,但是申請「有效憑證」大部分是要錢的! 官方文件也有提到將 Registry 設定到 insecure 清單可忽略 TLS 協定(不過不建議) 本文章將介紹將 Docker Registry 設定在 insecure 清單進行存取。
Docker 環境將建立在 Ubuntu Server
文章節錄至 Docker 官方文件,可直接到參考資料檢視官方文件。
部分名詞為自行翻譯,若有誤可在下方留言告知,將盡速修正
文章環境(主機、用戶端)
- 作業系統
- Ubuntu 16.04.3 LTS
- Docker 版本
- Docker version 17.06.0-ce
主機清單
- DockerRegistry
- 建立 docker registry 的 Ubuntu Server
- DockerClient
- 取得 DockerRegistry Docker image 的 Ubuntu Server
建立 Docker Registry
在「DockerRegistry」上執行 registry 的 docker images。
docker run -d -p 5000:5000 --name registry registry
啟用 container 後,私有 Registry 就建立完成。

更多進階設定請參考官方文件
設定「DockerRegistry」為 insecure
接下來在「DockerClient」將「DockerRegistry」設定為到 insecure 清單。
insecure 設定檔路徑「/etc/docker/daemon.json」
檔案不存在時請自行建立(Windows 環境的設定檔路徑請參考官方文件)

將「DockerRegistry」位址與連接埠設定到 insecure 清單
{
"insecure-registries":["192.168.0.90:5000"]
}

感謝網友 Hank Fang 補充說明,此步驟完成後需要重新啟動 docker 服務才可以生效(官方文件中也有說明)
重新啟動指令參考下面回復 :)
驗證設定結果
重新命名「DockerClient」的 docker image tag
[domain||ip-address]:[port]/[image_name]
docker tag redis 192.168.0.90:5000/private-redis


使用 docker push 將 image push 到「DockerRegistry」的 Registry
docker push 192.168.0.90:5000/private-redis


刪除 push 上去的 docker image
docker rmi 192.168.0.90:5000/private-redis

刪除後,本機的 image 清單中沒有名為「192.168.0.90:5000/private-redis」的 docker image

重新 pull 剛剛上傳的 docker image
docker pull 192.168.0.90:5000/private-redis

成功從「DockerRegistry」的 Registry 取得指定的 docker image

沒有設定 insecure 的問題
若「DockerRegistry」的 Registry 並沒有設定到 insecure 清單,會出現下列錯誤。

參考資料
留言
將「DockerRegistry」位址與連接埠設定到 insecure 清單
回覆刪除這個步驟做完後須重啟docker service才會生效喔
systemctl restart docker
感謝您的教學步驟,很實用
謝謝您的留言,已經將文章做補充 / 很高興能夠對您有幫助
刪除