欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

docker私有仓库构建

程序员文章站 2024-03-12 21:58:44
...

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

仓库机器(192.168.51.232)

[[email protected] ~]# 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

设置
[[email protected] ~]# 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

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

[[email protected] ~]# curl 192.168.51.232:5000/v2/_catalog
{"repositories":["nginx"]}

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

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