当前位置:   article > 正文

搭建私有docker仓库_/etc/containers/registries.conf

/etc/containers/registries.conf

搭建私有docker仓库

参考

参考
centos7搭建docker本地regsitry
官方英文文档

服务器端

私有创建服务器系统是CentOS7系统。
注意,以非安全模式(insecure)启动后,启动后只能以http协议访问。

配置docker

打开docker配置文件vi /etc/sysconfig/docker,增加--insecure-registry=192.168.3.36:5000
结果如下:

# /etc/sysconfig/docker

# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --insecure-registry=192.168.3.36:5000'
if [ -z "${DOCKER_CERT_PATH}" ]; then
    DOCKER_CERT_PATH=/etc/docker
fi

# Do not add registries in this file anymore. Use /etc/containers/registries.conf
# instead. For more information reference the registries.conf(5) man page.

# Location used for temporary files, such as those created by
# docker load and build operations. Default is /var/lib/docker/tmp
# Can be overriden by setting the following environment variable.
# DOCKER_TMPDIR=/var/tmp

# Controls the /etc/cron.daily/docker-logrotate cron job status.
# To disable, uncomment the line below.
# LOGROTATE=false

# docker-latest daemon can be used by starting the docker-latest unitfile.
# To use docker-latest client, uncomment below lines
#DOCKERBINARY=/usr/bin/docker-latest
#DOCKERDBINARY=/usr/bin/dockerd-latest
#DOCKER_CONTAINERD_BINARY=/usr/bin/docker-containerd-latest
#DOCKER_CONTAINERD_SHIM_BINARY=/usr/bin/docker-containerd-shim-latest
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26

重启docker服务

systemctl restart docker.service
  • 1

启动容器

//创建并启动容器
docker run -p 5000:5000 --name registry -v /home/chenyuan/docker/registry/volumes:/var/lib/registry --privileged=true --restart=always -d registry
 docker pull tomcat
 //给镜像一个别名。注意别名格式
 docker tag tomcat localhost:5000/cy/tomcat
  • 1
  • 2
  • 3
  • 4
  • 5

验证

访问http://192.168.3.36:5000/v2/_catalog(ip换成你自己的私有仓库地址)结果如下:

{"repositories":["cy/tomcat"]}
  • 1

说明安装成功了

客户机端

客户端是windows系统
我的windows客户器上打开C:\ProgramData\Docker\config,增加配置"insecure-registries": [ "192.168.3.36:5000" ]。结果如下

{  "insecure-registries": [    "192.168.3.36:5000"  ],  "debug": true,  "experimental": true}
  • 1

摘取镜像

docker pull 192.168.3.36:5000/cy/tomcat
  • 1

注意,192.168.3.36:5000是仓库注册服务器地址,cy/tomcat是仓库名。
注册服务器是存放仓库的具体服务器,每个服务器上可以有多个仓库,每个仓库下有多个镜像。

结果如下

PS C:\WINDOWS\system32> docker pull 192.168.3.36:5000/cy/tomcat
Using default tag: latest
latest: Pulling from cy/tomcat
Digest: sha256:37b0c72d0d030839e0974ed3e803f2b65a1cf2403d2b2ca1083f096ae2dc57cc
Status: Image is up to date for 192.168.3.36:5000/cy/tomcat:latest
  • 1
  • 2
  • 3
  • 4
  • 5

说明成功了

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/159052?site
推荐阅读
相关标签
  

闽ICP备14008679号