Linux之Docker私有仓库的搭建

简介: Linux之Docker私有仓库的搭建私有仓库的搭建下载registry镜像[root@toto6 images]# docker pull registery:2[root@toto6 images]# docker images registryREPOSITORY TAG IMAGE ...

Linux之Docker私有仓库的搭建
私有仓库的搭建

下载registry镜像

[root@toto6 images]# docker pull registery:2

[root@toto6 images]# docker images registry
REPOSITORY TAG IMAGE ID CREATED SIZE
registry 2 f32a97de94e1 4 months ago 25.8MB=

运行此容器

[root@toto6 images]# docker run -d --name registry -p 5000:5000 -v /opt/registry:/var/lib/registry registry:2

创建并运行容器,设置数据卷,并做端口映射

查看容器运行运行情况以及映射端口开启情况:

[root@toto6 images]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bc3bcd6346f4 registry:2 “/entrypoint.sh /etc…” About a minute ago Up About a minute 0.0.0.0:5000->5000/tcp registry
[root@toto6 images]# netstat -antlp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 656/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 778/master
tcp 0 0 172.25.13.160:22 172.25.13.250:57074 ESTABLISHED 2036/sshd: root@pts
tcp6 0 0 :::22 :: LISTEN 656/sshd
tcp6 0 0 ::1:25 :: LISTEN 778/master
tcp6 0 0 :::5000 :: LISTEN 19841/docker-proxy

上传镜像到本地仓库

再上传镜像的时候,一般会默认上传到docker hub官方仓库,现在需要上传到本地自己创建的仓库,需要指定上传的地址以及端口。如果使用ip默认使用tls加密,目前没有设置,所有直接指定到本机的端口。

需要对本地需要进行上传的镜像进行修改标签:

[root@toto6 images]# docker tag nginx:latest localhost:5000/nginx
[root@toto6 images]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx v4 cb475e8f4412 4 hours ago 23.7MB
nginx latest f68d6e55e065 11 days ago 109MB
localhost:5000/nginx latest f68d6e55e065 11 days ago 109MB
registry 2 f32a97de94e1 4 months ago 25.8MB
rhel7 latest 0a3eb3fde7fd 5 years ago 140MB
gcr.io/distroless/base latest 9a255d5fe262 49 years ago 16.8MB

上传修改过标签的镜像到本地仓库:

[root@toto6 images]# docker push localhost:5000/nginx # 上传
The push refers to repository [localhost:5000/nginx]
d2f0b6dea592: Pushed
197c666de9dd: Pushed
cf5b3c6798f7: Pushed
latest: digest: sha256:00be67d6ba53d5318cd91c57771530f5251cfbe028b7be2c4b70526f988cfc9f size: 948
[root@toto6 images]# curl localhost:5000/v2/_catalog # 核实是否上传成功
{“repositories”:[“nginx”]}

查看其数据卷挂载点

运行容器的时候,设置了数据卷,可以子阿宿主机查看上传的结果:

[root@toto6 images]# cd /opt/registry/
[root@toto6 registry]# ls
docker
[root@toto6 registry]# cd docker/
[root@toto6 docker]# ls
registry
[root@toto6 docker]# cd registry/
[root@toto6 registry]# ls
v2
[root@toto6 registry]# cd v2/
[root@toto6 v2]# ls
blobs repositories
[root@toto6 v2]# cd repositories/
[root@toto6 repositories]# ls
nginx

此时创建的私有仓库远程主机无法使用,并且不够安全,此时则可以采用私有仓库加证书加密的方式来创建私有仓库

作者:若无其事的苹果
来源:CSDN
原文:https://blog.csdn.net/qq_36016375/article/details/96047991
版权声明:本文为博主原创文章,转载请附上博文链接!

相关文章
|
7天前
|
Cloud Native Linux 开发者
【Docker】Docker:解析容器化技术的利器与在Linux中的关键作用
【Docker】Docker:解析容器化技术的利器与在Linux中的关键作用
|
4天前
|
存储 Linux 文件存储
Linux使用Docker部署Traefik容器并实现远程访问管理界面-1
Linux使用Docker部署Traefik容器并实现远程访问管理界面
|
4天前
7.Docker 私有仓库
7.Docker 私有仓库
|
4天前
|
NoSQL Linux Shell
2.Docker常用命令(linux)
2.Docker常用命令(linux)
|
6天前
|
Linux 网络安全 Docker
【Linux】-docker配置容器并打包成镜像
【Linux】-docker配置容器并打包成镜像
|
6天前
|
运维 监控 Linux
【专栏】举几个Docker ps 命令的例子,Linux运维必知
【4月更文挑战第28天】本文介绍了Docker命令`docker ps`的使用,包括列出运行中的容器、筛选特定容器、组合使用与其他命令配合以及在故障排查中的应用。通过基础和高级用法示例,如列出所有容器、搜索特定镜像、监控资源使用等,帮助读者理解和提升容器管理效率。对于Linux运维工程师,掌握`docker ps`是必备技能。
|
12天前
|
Ubuntu Linux 测试技术
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试(下)
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试
42 1
|
12天前
|
Ubuntu Linux 测试技术
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试(上)
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试
47 0
|
12天前
|
Ubuntu Linux 网络安全
Linux(31)Rockchip RK3568 Ubuntu22.04上部署 Docker: 问题与解决方案
Linux(31)Rockchip RK3568 Ubuntu22.04上部署 Docker: 问题与解决方案
61 0
|
12天前
|
Linux 开发工具 Android开发
Docker系列(1)安装Linux系统编译Android源码
Docker系列(1)安装Linux系统编译Android源码
16 0