8. Registry搭建docker私仓

Docker Registry

Docker Registry是官方提供的工具,用于构建私有镜像仓库。

环境搭建

Docker Registry也是Docker Hub提供的一个镜像,可以直接拉取运行。

步骤:

  1. 拉取镜像
1
docker pull registry
  1. 启动Docker Registry
1
docker run -d -p 5000:5000 -v /app/myregistry/:/tmp/registry --privileged=true registry
  1. 验证(查看私服中的所有镜像)
1
curl http://192.168.xxx.xxx:5000/v2/_catalog

Registry会返回json格式的所有镜像目录

向Registry私仓中上传镜像

配置docker允许接收http请求

(配置方式和上传到nexus私仓相同)。

修改/etc/docker/daemon.json,添加insecure-registries允许http:

1
2
3
4
{
"registry-mirros": ["https://xxxx.mirror.aliyuncs.com"],
"insecure-registries": ["192.168.xxx.xxx:5000"]
}

然后重启docker:(新版本的docker会立即生效)

1
2
3
4
5
6
7
# centos6 的命令
sudo chkconfig daemon-reload
sudo service docker restart

# centos7 的命令
sudo systemctl daemon-reload
sudo systemctl restart docker

推送到私仓

步骤:

  1. 添加一个对应私仓地址的tag
1
docker tag lee/myubuntu:1.0.1 192.168.xxx.xxx:5000/lee/myubuntu:1.0.1
  1. push到私仓
1
docker push 192.168.xxx.xxx:5000/lee/myubuntu:1.0.1
  1. 查看私仓中镜像目录验证
1
curl http://192.168.xxx.xxx:5000/v2/_catalog

拉取验证:

1
docker pull 192.169.xxx.xxx:5000/lee/myubuntu:1.0.1

8. Registry搭建docker私仓
http://binbo-zappy.github.io/2024/12/07/docker/8-Registry搭建docker私仓/
作者
Binbo
发布于
2024年12月7日
许可协议