Docker私有仓库搭建测试

首次运行仓库容器,由于本地没有找到仓库镜像registry,改为直接从公共仓库下载,然后按照指定的参数运行,其中将本地目录/opt/data/registry映射到容器内目录/tmp/registry,此目录作为之后镜像上传到私有仓库保存镜像的位置。

docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry registry
Unable to find image 'registry:latest' locally
latest: Pulling from library/registry
c87736221ed0: Pull complete
1cc8e0bb44df: Pull complete
54d33bcb37f5: Pull complete
e8afc091c171: Pull complete
b4541f6d3db6: Pull complete
Digest: sha256:8004747f1e8cd820a148fb7499d71a76d45ff66bac6a29129bfdbfdc0154d146
Status: Downloaded newer image for registry:latest
0eb9176acb612fd33daf11ac3e8245a746872144fe90e3792a369adbe70a856e

  • 私有仓库默认保存镜像的目录路径/tmp/registry

查询本地的私有仓库镜像

docker images |grep registry
registry                     latest              f32a97de94e1        3 months ago        25.8MB

测试镜像上传至私有仓库

  • 在另外一台Ubuntu docker上,下载一个zabbix/zabbix-proxy-mysql镜像
docker pull zabbix/zabbix-proxy-mysql
Using default tag: latest
latest: Pulling from zabbix/zabbix-proxy-mysql
e7c96db7181b: Pull complete
bbef9e2ae56a: Pull complete
c4e54b2d2f6b: Pull complete
1beae7cbf894: Pull complete
Digest: sha256:c4a03e7e0fffd7e7fb26e70c61ddaac86eaee4a5bc6069d65668294cb3077ddb
Status: Downloaded newer image for zabbix/zabbix-proxy-mysql:latest

  • 将zabbix/zabbix-proxy-mysql:latest镜像标记为“10.10.10.15:5000/test”
docker tag zabbix/zabbix-proxy-mysql:latest 10.10.10.15:5000/test
  • 将标记的镜像上传至建立好的私有仓库
#上传镜像
docker push 10.10.10.15:5000/test
The push refers to repository [10.10.10.15:5000/test]

#由于高版本docker存在安全性高的问题,采用http上传镜像会失败
Get https://10.10.10.15:5000/v2/: http: server gave HTTP response to HTTPS client

  • 在需要上传镜像的主机上修改或新建 /etc/docker/daemon.json

{
        "registry-mirrors": ["https://registry.docker-cn.com"],
        "insecure-registries": ["10.10.10.15:5000"]
}

  • 重启docker服务后,再次测试上传镜像成功
docker push 10.10.10.15:5000/test
The push refers to repository [10.10.10.15:5000/test]
1499b0670a95: Pushed
eeb6c6c1b7d6: Pushed
aaa598425d72: Pushed
f1b5933fe4b5: Pushed
latest: digest: sha256:c4a03e7e0fffd7e7fb26e70c61ddaac86eaee4a5bc6069d65668294cb3077ddb size: 1160
  • 查看私有仓库中的镜像
#在私有仓库主机上执行
curl http://127.0.0.1:5000/v2/_catalog
{"repositories":["test"]}

其他镜像公共仓库

存在的疑问:

在本地挂载到容器的目录/opt/data/registry,或是容器默认仓库目录/tmp/registry,cd到目录内,通过ls并没有看到成功上传的镜像?

镜像文件无法通过常规ls命令查看吗?

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值