docker 搭建本地私有倉庫及映象上傳時HTTPS client問題解決(windows 10)
阿新 • • 發佈:2018-11-20
1, 設定容器可訪問的盤:
點選小鯨魚圖片,滑鼠右鍵-》settings->Shared Drives,進行設定,選擇相應的盤,比如E盤,然後點選“Apply”,如圖
2, 下載registry映象:
執行命令docker pull registry,就可以直接在官網下載
3,建立本地私有倉庫
下載好registry後,執行以下命令即可完成本地私有倉庫的建立,注意(要先在E盤中建立registry資料夾)
docker run -d -p 5000:5000 -v E:/registry:/var/lib/registry registry:latest
注:-v資料卷掛載的路徑為/var/lib/registry,否則沒法儲存資料,registry重啟後已push的映象會丟失。
4,檢驗私有倉庫是否建立成功
registry啟動成功後,可以在瀏覽器輸入http://10.244.10.19:5000/v2/看頁面是否有“{}”輸出,如果有則本地倉庫建立成功。
注:10.244.10.19為自己的主機ip
5,上傳映象
1)檢視已有映象:
E:\docker>docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu 12.3 c3d2a7b54f0e 9 hours ago 505MB user/ubuntu 12.3 c3d2a7b54f0e 9 hours ago 505MB 552277/ubuntu 12.3 c3d2a7b54f0e 9 hours ago 505MB ubuntu latest ea4c82dcd15a 11 days ago 85.8MB registry latest 2e2f252f3c88 6 weeks ago 33.3MB 552277/hello-world 1.0 4ab4c602aa5e 7 weeks ago 1.84kB hello-world latest 4ab4c602aa5e 7 weeks ago 1.84kB
2)對映象做標記:
docker tag ubuntu:12.3 10.244.10.19:5000/test:1.0
3) 執行上傳命令docker push:
docker push 10.244.10.19:5000/test:1.0
備註:執行docker push命令時,如果報錯如下:
E:\docker>docker push 10.244.10.19:5000/test The push refers to repository [10.244.10.19:5000/test] Get https://10.244.10.19:5000/v2/: http: server gave HTTP response to HTTPS client
原因:registry的啟動預設使用的是http,但平時使用docker push或者docker pull進行映象操作時預設使用的是https。
解決:進行如下配置,配置好後當從10.244.10.19:5000倉庫上進行push或pull時,docker就使用http進行連結。
6,映象下載:
docker pull 10.244.10.19:5000/test
E:\docker>docker pull 10.244.10.19:5000/test
Using default tag: latest
latest: Pulling from test
Digest: sha256:1a6fd470b9ce10849be79e99529a88371dff60c60aab424c077007f6979b4812
Status: Downloaded newer image for 10.244.10.19:5000/test:latest