Docker Registry
Docker Registry是官方提供的工具,用于构建私有镜像仓库。
环境搭建
Docker Registry也是Docker Hub提供的一个镜像,可以直接拉取运行。
步骤:
- 拉取镜像
docker pull registry
- 启动Docker Registry
docker run -d -p 5000:5000 -v /app/myregistry/:/tmp/registry --privileged=true registry
- 验证(查看私服中的所有镜像)
curl http://172.50.30.100:5000/v2/_catalog
Registry会返回json格式的所有镜像目录
向Registry私仓中上传镜像
将镜像修改为符合规范的Tag
[root@localhost ~]# docker tag ubuntu/ifconfig:1.2 172.50.30.100:5000/ubuntu/ifconfig:1.2
配置docker允许接收http
请求
docker默认不允许http方式推送镜像
修改/etc/docker/daemon.json
,添加insecure-registries
允许http:
{
"registry-mirros": ["https://xxxx.mirror.aliyuncs.com"], #注意这里要写个逗号
"insecure-registries": ["192.168.xxx.xxx:5000"] #添加使其解除限制
}
如果配置不生效,建议重启docker
推送镜像到本地私仓
1.push到私仓 :
[root@localhost ~]# docker push 172.50.30.100:5000/ubuntu/ifconfig:1.2
The push refers to repository [172.50.30.100:5000/ubuntu/ifconfig]
af9216e52108: Pushed
9f54eef41275: Pushed
1.2: digest: sha256:1d3a02eb0a82c370bfc8c42104b7a02985d0bebf7ceccd22ce4ba3013831160b size: 74.1
2.拉取验证:
[root@localhost ~]# docker pull 172.50.30.100:5000/ubuntu/ifconfig:1.2
1.2: Pulling from ubuntu/ifconfig
Digest: sha256:1d3a02eb0a82c370bfc8c42104b7a02985d0bebf7ceccd22ce4ba3013831160b
Status: Downloaded newer image for 172.50.30.100:5000/ubuntu/ifconfig:1.2
172.50.30.100:5000/ubuntu/ifconfig:1.2