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
相關文章
相關標籤/搜索