仓库是集中存放镜像的地方
注册服务器是存放仓库的服务器,每个服务器上有多个仓库
搜索镜像
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"]}