Docker将本地的镜像上传到私有仓库

使用register镜像创建私有仓库

bash 复制代码
[root@openEuler-node1 ~]# docker run --restart=always -d -p 5000:5000 -v /opt/data/regostry:/var/lib/registry registry:2
bash 复制代码
[root@openEuler-node1 ~]# docker images
REPOSITORY                                          TAG         IMAGE ID       CREATED        SIZE
registry                                            2           a8781fe3b7a2   5 weeks ago    25.4MB
busybox                                             latest      3f57d9401f8d   6 weeks ago    4.26MB
ubuntu                                              18.04       f9a80a55f492   9 months ago   63.2MB
centos                                              7           eeb6ee3f44bd   2 years ago    204MB

(1) 先将本地仓库打上合适的标签

bash 复制代码
[root@openEuler-node1 ~]# docker tag busybox:latest 192.168.136.55:5000/busybox:v1

(2)尝试上传镜像

bash 复制代码
[root@openEuler-node1 ~]# docker pull 192.168.136.55:5000/busybox:v1
Error response from daemon: Get "https://192.168.136.55:5000/v2/": http: server gave HTTP response to HTTPS client

上传镜像失败,原因:docker上传下载默认只支持https协议,搭建的私有仓库是https协议。

(3) 修改重启docker服务

bash 复制代码
[root@openEuler-node1 ~]# mkdir /etc/docker
[root@openEuler-node1 ~]# vim /etc/docker/daemon.json

{
        "insecure-registries":["192.168.136.55:5000"]
}       
[root@openEuler-node1 ~]# systemctl daemon-reload 
[root@openEuler-node1 ~]# systemctl restart docker.service 

(4)再次上传镜像,成功

bash 复制代码
[root@openEuler-node1 ~]# docker push 192.168.136.55:5000/busybox:v1
The push refers to repository [192.168.136.55:5000/busybox]
2e112031b4b9: Pushed 
v1: digest: sha256:d319b0e3e1745e504544e931cde012fc5470eba649acc8a7b3607402942e5db7 size: 527

(5)验证

bash 复制代码
[root@openEuler-node1 ~]# ll /opt/data/regostry/docker/registry/v2/repositories/
总用量 4
drwxr-xr-x 5 root root 4096  3月  3 11:58 busybox

我们可以用可视化界面registry-web(docker自带的)来管理

bash 复制代码
[root@openEuler-node1 ~]# docker run -d -p 8080:8080 --name registry-web --restart=always --link b2878bdb5e1b -e registry_url=http://192.168.136.55:5000/v2 -e registry_name=localhost:5000 hyper/docker-registry-web:latest
相关推荐
“码”力全开14 分钟前
【架构深探】基于Docker与GB28181/RTSP的边缘计算AI视频管理平台:异构算力调度与源码交付实践
人工智能·docker·架构
月巴月巴白勺合鸟月半18 分钟前
在Linux下开发桌面程序
linux·运维·服务器
zh路西法19 分钟前
【tmux入门】终端分屏、SSH远程守护与一键启动脚本
linux·运维·ssh·bash
qq_1631357525 分钟前
Linux 【03-pwd命令超详细教程】
linux
学途路漫漫26 分钟前
Ubuntu 24.04 国内网络环境全面优化指南
linux·网络·ubuntu
c2385626 分钟前
GDB 进程概念详解(下篇)—— 多进程与进阶调试能力
linux·服务器·数据库
RisunJan29 分钟前
Linux命令-php(PHP语言的命令行接口)
linux·php
A_humble_scholar30 分钟前
Linux(八) 进程内存全景:环境变量、main 函数参数与虚拟地址空间全链路深度解析
linux·运维·服务器
longforus35 分钟前
linux上播放音乐的终极解决方案
linux·音频·折腾
xcLeigh37 分钟前
鸿蒙PC平台 Shotwell 照片管理器适配实战:从 Linux GNOME 到 鸿蒙PC 的 Electron 迁移
linux·electron·harmonyos·鸿蒙·shotwell·照片管理器