docker搭建私有仓库

docker搭建私有仓库

部署环境:

两台centos7虚拟机,其中一台作为registry
docker:18.06-ce
已经配置好阿里云镜像加速,阿里云镜像加速配置可以参考:[https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors](https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors)

registry节点

首先在registry节点,拉取registry镜像

[root@host1 se-eureka]#  docker pull registry

启动registry镜像服务

[root@host1 se-eureka]#  docker run -itd -v /data/registry:/var/lib/registry -p 5000:5000 --restart=always --name registry registry:latest 

修改daemon.json文件

[root@host1 se-eureka]# vim /etc/docker/daemon.json 
[root@host1 se-eureka]# cat /etc/docker/daemon.json 
{
  "registry-mirrors": ["https://jrhfzcbf.mirror.aliyuncs.com"],
  "insecure-registries": ["192.168.1.36:5000"],
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"
  ]
}

重启docker服务

systemctl daemon-reload docker
systemclt restart docker

测试:

[root@host1 se-eureka]# curl http://192.168.1.36:5000/v2/_catalog
{"repositories":[""]}

其他节点

[root@host3 ~]# vim /etc/docker/daemon.json
[root@host3 ~]# cat /etc/docker/daemon.json 
{
  "registry-mirrors": ["https://jrhfzcbf.mirror.aliyuncs.com"],
  "insecure-registries": ["192.168.1.36:5000"],
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"
  ]
}

重启docker服务

[root@host3 ~]# systemctl daemon-reload docker
[root@host3 ~]# systemctl restart docker

测试:

[root@host1 se-eureka]# docker pull nginx
[root@host1 se-eureka]# docker tag nginx 192.168.1.36:5000/mynginx:v1
[root@host1 se-eureka]# docker push 192.168.1.36:5000/mynginx

然后在另外一台主机上

[root@host2 ~]# docker pull 192.168.1.36:5000/mynginx:v1
v1: Pulling from mynginx
8d691f585fa8: Pull complete 
5b07f4e08ad0: Pull complete 
abc291867bca: Pull complete 
Digest: sha256:f56b43e9913cef097f246d65119df4eda1d61670f7f2ab720831a01f66f6ff9c
Status: Downloaded newer image for 192.168.1.36:5000/mynginx:v1
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • [TOC] 一、前提和准备条件 搭建私有仓库需要以下条件: 1.已安装Docker服务的服务端 2.测试docke...
    溯水心生阅读 705评论 0 1
  • 和Mavan的管理一样,Dockers不仅提供了一个中央仓库,同时也允许我们使用registry搭建本地私有仓库。...
    阮凯_7423阅读 1,183评论 2 1
  • 如果不想用私有镜像库,你可以用docker的库 https://hub.docker.com 环境准备 环境:两个...
    SkTj阅读 660评论 1 1
  • 前言 上一篇文章我们已经使用过公有仓库,现在我们学习一下如何搭建私有仓库。私有仓库:顾名思义是私人使用或者公司内部...
    崔健敏阅读 854评论 0 1
  • 1、拉取 registry 镜像 命令docker pull registry 2、启动容器创建私有仓库 启动命令...
    IT锟阅读 418评论 1 3

友情链接更多精彩内容