首页 > 系统服务 > 详细

部署docker-registry+ui shell 域名证书-用户认证

时间:2020-07-29 02:30:30      阅读:149      评论:0      收藏:0      [点我收藏+]

#部署docker-registry+ui shell

docker registry 配置域名证书, 用户密码认证, 轻量UI
ansible部署docker-registry+ui https://www.cnblogs.com/elvi/p/13394492.html


#!/bin/bash
#run.docker-registry.sh
#部署docker registry +ui
# By Elvin

#目录
data_dir=/data/docker/docker-registry
mkdir -p $data_dir
cd $data_dir

#域名证书(使用我的证书为例)
domain_name=hub.elvin.vip
download_url=http://files.elvin.vip/docker
if [  ! -e ${domain_name}_private.key -o  ! -e ${domain_name}_private.key ];then
curl -so hub.elvin.vip_private.key    ${download_url}/${domain_name}_private.key
curl -so hub.elvin.vip_full_chain.pem ${download_url}/${domain_name}_full_chain.pem
fi

#创建密码文件,用户admin 密码 docker
docker run --rm alivv/htpasswd admin docker >htpasswd

#创建网络 registry-net
if [ $(docker network ls |grep registry-ui-net |wc -l) -ne 1 ];then
    docker network create --subnet 10.20.20.0/24 --gateway 10.20.20.1 registry-net
fi

#registry-srv
docker rm -f registry-srv &>/dev/null
docker run -dit --name registry-srv --privileged=true --restart=always --net registry-net -p 443:443 --memory 512M -v $data_dir:/var/lib/registry -v /etc/localtime:/etc/localtime:ro -e REGISTRY_AUTH=htpasswd -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" -e REGISTRY_AUTH_HTPASSWD_PATH=/var/lib/registry/htpasswd -e REGISTRY_HTTP_ADDR=0.0.0.0:443 -e REGISTRY_STORAGE_DELETE_ENABLED=true -e REGISTRY_HTTP_TLS_KEY=/var/lib/registry/hub.elvin.vip_private.key -e REGISTRY_HTTP_TLS_CERTIFICATE=/var/lib/registry/hub.elvin.vip_full_chain.pem registry

#registry-ui
docker rm -f registry-ui  &>/dev/null
docker run -d --name registry-ui --restart=always --memory 64M --net registry-net -p 80:80 -v /etc/localtime:/etc/localtime:ro -e REGISTRY_URL=https://registry-srv:443 -e PULL_URL=${domain_name} -e DELETE_IMAGES=true -e REGISTRY_TITLE="Docker registry" joxit/docker-registry-ui:1.3-static

#docker pull images

#下载images
docker pull alpine
docker pull alpine:3.12

#docker tag 添加仓库前缀地址
docker tag  alpine  hub.elvin.vip/demo/alpine
docker tag  alpine:3.12  hub.elvin.vip/demo/alpine:3.12

#登录
docker login hub.elvin.vip

#images push
docker push hub.elvin.vip/demo/alpine
docker push hub.elvin.vip/demo/alpine:3.12

#浏览器登录查看

技术分享图片


#remove demo
docker rm -f registry-srv 
docker rm -f registry-ui 
docker network rm registry-ui-net

registry非本机,设置hosts解析 ip hub.elvin.vip
Docker Registry UI 当前最新版1.5, 界面有改动,显示pull hash值
github https://github.com/Joxit/docker-registry-ui

部署docker-registry+ui shell 域名证书-用户认证

原文:https://www.cnblogs.com/elvi/p/13394449.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!