Docker仓库的搭建 (私有仓库 用户认证 远程连接)

本文详细介绍了如何搭建Docker私有仓库,包括使用registry镜像,配置TLS加密确保安全,设置远程主机连接以及添加用户认证功能。通过这些步骤,可以实现安全的内部镜像管理和分发。
摘要由CSDN通过智能技术生成

1.官方镜像仓库仓库

  • 先在https://hub.docker.com 注册帐号
    docker login登录docker hub 输入自己的用户名和密码
[root@server2 sysctl.d]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: wnccmyr
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

docker tag ubuntu:latest wnccmyr/ubuntu.latest给自己本地的镜像打上标签

[root@server2 sysctl.d]# docker tag ubuntu:latest wnccmyr/ubuntu.latest
[root@server2 sysctl.d]# docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
wnccmyr/ubuntu.latest   latest              d70eaf7277ea        4 weeks ago         72.9MB
ubuntu                  latest              d70eaf7277ea        4 weeks ago         72.9MB

docker push wnccmyr/ubuntu:latest把镜像上传
在这里插入图片描述

  • 登录网页 ,发现已经成功上传
    在这里插入图片描述

2. 搭建私有仓库

  • dockerhub需要联网,慢,并且所有人都可以访问到,不够安全,企业内部的镜像放到外网不安全,docker公司把registry开源,可以搭建自己的私有仓库
  1. docker pull registry:2下载registry镜像
  2. docker run -d --name registry -p 5000:5000 -v /opt/registry:/var/lib/registry registry:2
    我把把他挂载到指定目录/opt/registry
    /var/lib/registry 目录自己可以查到,一般是默认目录
    在这里插入图片描述
  3. 上传本地镜像到registry
##给我本地本就有的镜像ubuntu打上标签 
[root@server1 registry]# docker tag ubuntu:latest localhost:5000/ubuntu:latest
[root@server1 registry]# docker push localhost:5000/ubuntu

在这里插入图片描述

  • 可以看下刚才自己指定的目录下已经存在
    在这里插入图片描述

  • 为了测试,把本地的ubuntu镜像删除
    docker rmi localhost:5000/ubuntu:latest
    docker rmi ubuntu:latest
    在这里插入图片描述

  • 从本地进行下载
    docker pull localhost:5000/ubuntu

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值