Docker安装配置私有仓库

docker私有仓库

docker私有仓库图例
私有仓库配置
主机名 ip地址 最低配置
registry 192.168.1.100 1CPU,1G内存
[root@registry ~]# yum install -y docker-distribution
[root@registry ~]# systemctl enable --now docker-distribution
[root@registry ~]# curl http://192.168.1.100:5000/v2/_catalog
{"repositories":[]}

仓库配置文件及数据存储路径

  • /etc/docker-distribution/registry/config.yml
  • /var/lib/registry/
  • 默认端口号 5000

查看私有镜像仓库中镜像名称或标签

  • curl http://仓库IP:5000/v2/_catalog
  • curl http://仓库IP:5000/v2/镜像名称/tags/list

注意:私有仓库中的镜像与docker images 看到的不是一个东西

docker客户端配置

所有node节点都需要配置,这里 docker-0001,docker-0002都要配置
cgroup驱动 docker默认 是cgroupfs
registry-mirrors 默认下载仓库,使用国内源能快一点
insecure-registries 私有仓库地址(重点)

#新建daemon.json文件:
[root@docker-0001 ~]# vim /etc/docker/daemon.json
{
    "exec-opts": ["native.cgroupdriver=systemd"],
    "registry-mirrors": ["https://hub-mirror.c.163.com"],
    "insecure-registries":["192.168.1.100:5000", "registry:5000"]
}
[root@docker-0001 ~]# docker rm -f $(docker ps -aq)
[root@docker-0001 ~]# systemctl restart docker
上传镜像
# 上传 myos:latest, myos:httpd, myos:nginx, myos:php-fpm
[root@docker-0001 ~]# docker tag myos:latest 192.168.1.100:5000/myos:latest
[root@docker-0001 ~]# docker push 192.168.1.100:5000/myos:latest
验证测试
[root@docker-0002 ~]# curl http://192.168.1.100:5000/v2/_catalog
{"repositories":["myos"]}
[root@docker-0002 ~]# curl http://192.168.1.100:5000/v2/myos/tags/list
{"name":"myos","tags":["latest"]}
# 使用远程镜像启动容器
[root@docker-0002 ~]# docker run  -itd -p 80:80 192.168.1.100:5000/myos:nginx 
Unable to find image '192.168.1.100:5000/myos:nginx' locally
nginx: Pulling from myos
7dc0dca2b151: Pull complete 
ee0506df88b5: Pull complete 
261f2c66fd1b: Pull complete 
65dac21edb30: Pull complete 
Digest: sha256:19c0b028294145ca32f175d57d2f890645982577d9a35f2c6f6a69534c4bc48f
Status: Downloaded newer image for 192.168.1.100:5000/myos:nginx
e31036b207c6869d618e3a935eaf3f41e3e3e4110f81598832bbd575e4d68e27

你可能感兴趣的:(Docker安装配置私有仓库)