之前在搭建K8s的时候,搭建过私有仓库,最近重新又搭建,发现当时写的文档有点乱,这次重新整理下;

仓库机器(192.168.51.232)

[root@localhost ~]# docker version
Client:
 Version:      17.03.1-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Mon Mar 27 17:05:44 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.03.1-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Mon Mar 27 17:05:44 2017
 OS/Arch:      linux/amd64
 Experimental: false

设置
[root@localhost ~]# cat /etc/docker/daemon.json 
{
    "storage-driver": "devicemapper",
    "insecure-registries":["192.168.51.232:5000"]
 }


拉取registry镜像
docker pull hub.c.163.com/library/registry:latest

运行仓库实例
docker run -d -p 5000:5000 --restart=always --name registry hub.c.163.com/library/registry:latest

测试
docker pull hub.c.163.com/library/nginx:latest
docker tag  hub.c.163.com/library/nginx 192.168.51.232:5000/nginx
docker push 192.168.51.232:5000/nginx

查看仓库镜像列表
curl 192.168.51.232:5000/v2/_catalog

其他机器访问该仓库需要设置
[root@swarm2 ~]# cat /etc/docker/daemon.json 
{
  "storage-driver": "devicemapper",
  "insecure-registries":["192.168.51.232:5000"]
}

[root@swarm2 ~]# curl 192.168.51.232:5000/v2/_catalog
{"repositories":["nginx"]}

PS:
可能有的同学按照如上操作步骤,仍旧走不通
那就试试将daemon.json改为如下

{
  "storage-driver": "devicemapper",
  "insecure-registries":["0.0.0.0"]
}
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐