docker-3.私有倉庫
倉庫是集中存放鏡像的地方
註冊服務器是存放倉庫的服務器,每個服務器上有多個倉庫
搜索鏡像
docker search ubuntu
從docker hub的ubuntu倉庫下載ubuntu鏡像
docker pull ubuntu
安裝docker-distribution
yum install -y docker-distribution
啟動服務並開機自啟
systemctl enable docker-distribution
systemctl start docker-distribution
或
通過官方提供的registry鏡像創建私有倉庫
docker run -d -p 5000:5000 -v /data/registry:/var/lib/registry registry
-v把registry的容器路徑/var/lib/registry映射到本機的 /data/registry
私有倉庫IP為 192.168.200.102
上傳鏡像到私有倉庫
標記鏡像為192.168.200.102:5000/ubuntu:16.04.3
docker tag ubuntu:16.04.3 192.168.200.102:5000/ubuntu:16.04.3
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.200.102:5000/ubuntu 16.04.3 747cb2d60bbe 11 days ago 122 MB
ubuntu 16.04.3 747cb2d60bbe 11 days ago 122 MB
上傳鏡像
docker push 192.168.200.102:5000/ubuntu:16.04.3
如出現報錯
The push refers to a repository [192.168.200.102:5000/ubuntu]
Get https://192.168.200.102:5000/v1/_ping: http: server gave HTTP response to HTTPS client
docker client創建daemon.json文件
vim /etc/docker/daemon.json
{ "insecure-registries":["192.168.200.102:5000"] }
systemctl restart docker
驗證
curl http://192.168.200.102:5000/v2/_catalog
{"repositories":["ubuntu"]}
curl http://192.168.200.102:5000/v2/ubuntu/tags/list
{"name":"ubuntu","tags":["16.04.3"]}
docker-3.私有倉庫