Docker搭建内网Registry

转载请注明出处 http://www.paraller.com
原文排版地址 点击跳转nginx

转载请注明出处 来源:paraller's blogdocker

由于本身的云主机pull/push image到Docker hub下载速度慢和常常性抽风,因而在本身的主机上搭建registry存放 image,简述搭建过程和列出遇到的坑。ubuntu

准备工做

docker容器启动配置文件

  • 使用官方的镜像
  • 暴露5000端口
  • registry的image会存在 /tmp/registry中,若是主机重启了image就丢失了,因此挂载在本机
  • 设定基本的变量环境

docker-compose.ymlcentos

registry:
 image: registry
 ports:
   - "5000:5000"
 volumes:
   - /opt/data/registry:/tmp/registry
 environment:
   - STORAGE_PATH:/tmp/registry
   - SETTINGS_FLAVOR:dev

nginx配置文件

  • 将本机IP映射成域名
  • 注意proxy_pass不带端口号

default.conf安全

# registry
server {
    listen       80 ;
    server_name docker.paraller.com;

    location / {
        proxy_pass http://$localeIP;
    }
}

docker配置文件

  • docker配置文件 centos在 /etc/sysconfig/docker ; ubuntu在 /etc/default/docker
  • 由于默认是只容许https上传下载,因此要指定安全地址
  • 重启docker服务

/etc/sysconfig/dockercurl

other_args="--insecure-registry docker.paraller.com:5000"

打好tag的须要上传的镜像

docker tag paraller/nginx  docker.paraller.com:5000/paraller/nginx:3.0

开始运行

  • docker-compose up -d registry
  • service nginx start
  • curl -i docker.paraller.com:5000
  • curl -i http://docker.paraller.com:5000/v1/search
  • docker push docker.paraller.com:5000/paraller/nginx:3.0
  • ls /opt/data/registry/ //检查镜像是否存在
  • docker pull docker.paraller.com:5000/paraller/nginx:3.0

常见问题

一、没有在docker文件配置过滤IPthis

Error response from daemon: invalid registry endpoint https://docker.paraller.com:5000/v0/: unable to ping registry endpoint https://docker.paraller.com:5000/v0/
v2 ping attempt failed with error: Get https://docker.paraller.com:5000/v2/: EOF
 v1 ping attempt failed with error: Get https://docker.paraller.com:5000/v1/_ping: EOF. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry docker.paraller.com:5000` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/docker.paraller.com:5000/ca.crt

二、标签制做错误url

Repository XXX not found
相关文章
相关标签/搜索