Docker-Registry

构建私有镜像仓库

{
  "registry-mirrors": ["https://kzttrsz7.mirror.aliyuncs.com"],
  "insecure-registries": ["172.16.1.108:5000"]
}

构建本地registry仓库

docker container run -d -p 5000:5000 --restart=always --name registry -v /opt/registry:/var/lib/registry registry

将本地的镜像修改tag并上传到本地仓库

docker tag nginx:latest 172.16.1.108:5000/nginx:v1
docker push 172.16.1.108:5000/nginx:v1

从本地仓库下载镜像

docker pull 172.16.1.108:5000/nginx:v1

启动带秘钥功能的registry容器

yum -y install httpd-tools
mkdir /opt/registry-auth
htpasswd -Bbn Cai qwe > /opt/registry-auth/hpasswd		#生成账户信息
cat /opt/registry-auth/htpasswd
docker container run -d -p 5000:5000 -v /opt/registry-auth/:/auth -v /opt/registry:/var/lib/registry --name registry-auth -e "REGISTRY_AUTH=htpasswd" -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" -e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd" registry

开启秘钥验证后,push都需要先登录才能进行操作

docker login 172.16.1.108:5000
posted @ 2021-08-26 11:14  Cai_HL  阅读(31)  评论(0编辑  收藏  举报
>