Docker:在DockerHub上创建私有仓库

文章目录

本篇开始要学习在DockerHub上搭建一个自己的私有仓库

Busybox

Busybox是一个集成了三百多个最常用Linux命令和工具的软件,BusyBox包含了很多工具,这里拉取该镜像推送到仓库中:

安装

shell 复制代码
apt install -y busybox
shell 复制代码
root@VM-24-7-ubuntu:~# busybox ls
snap
root@VM-24-7-ubuntu:~# busybox ifconfig
docker0   Link encap:Ethernet  HWaddr 02:42:E3:E1:4B:6E  
          inet addr:172.17.0.1  Bcast:172.17.255.255  Mask:255.255.0.0
          inet6 addr: fe80::42:e3ff:fee1:4b6e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:483 errors:0 dropped:0 overruns:0 frame:0
          TX packets:612 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:82394 (80.4 KiB)  TX bytes:80198 (78.3 KiB)

BusyBox使用也没有任何难度,直接使用即可

创建仓库

这一步很简单,就按提示进行创建即可:

推送镜像到仓库

拉取BusyBox镜像

shell 复制代码
root@VM-24-7-ubuntu:~# docker pull busybox
Using default tag: latest
latest: Pulling from library/busybox
ec562eabd705: Pull complete 
Digest: sha256:9ae97d36d26566ff84e8893c64a6dc4fe8ca6d1144bf5b87b2b85a32def253c7
Status: Downloaded newer image for busybox:latest
docker.io/library/busybox:latest

给镜像打标签

shell 复制代码
root@VM-24-7-ubuntu:~# docker tag busybox:latest zhaobohan/mybusybox:v0.1

此时我们的Docker仓库中就会多出来这样的镜像:

shell 复制代码
root@VM-24-7-ubuntu:~# docker images
REPOSITORY                    TAG       IMAGE ID       CREATED         SIZE
zhaobohan/mybusybox           v0.1      65ad0d468eb1   12 months ago   4.26MB

现在推送镜像到仓库中:

不过这里,可能是由于国内访问限制的原因,我在进行Docker push的过程中,一直不能push到官网仓库中,一直显示retrying,我们这里就换个方式,使用腾讯云厂商提供的国内的仓库

shell 复制代码
root@VM-24-7-ubuntu:~# docker push zhaobohan/mybusybox:v0.1
The push refers to repository [docker.io/zhaobohan/mybusybox]
d51af96cf93e: Pushing  4.495MB

换到腾讯云

然后继续进行推送,此时就可以推送成功了:

shell 复制代码
root@VM-24-7-ubuntu:~# docker pull busybox
Using default tag: latest
latest: Pulling from library/busybox
ec562eabd705: Pull complete 
Digest: sha256:9ae97d36d26566ff84e8893c64a6dc4fe8ca6d1144bf5b87b2b85a32def253c7
Status: Downloaded newer image for busybox:latest
docker.io/library/busybox:latest
root@VM-24-7-ubuntu:~# docker tag busybox ccr.ccs.tencentyun.com/zhaobohan/mybusybox:your_tag
root@VM-24-7-ubuntu:~# docker images
REPOSITORY                                   TAG        IMAGE ID       CREATED         SIZE
ccr.ccs.tencentyun.com/zhaobohan/mybusybox   your_tag   65ad0d468eb1   12 months ago   4.26MB
root@VM-24-7-ubuntu:~# docker push ccr.ccs.tencentyun.com/zhaobohan/mybusybox:your_tag
The push refers to repository [ccr.ccs.tencentyun.com/zhaobohan/mybusybox]
d51af96cf93e: Pushed 
your_tag: digest: sha256:28e01ab32c9dbcbaae96cf0d5b472f22e231d9e603811857b295e61197e40a9b size: 527

在腾讯云仓库中也能看到:

相关推荐
不灭的程序员阿澄4 小时前
在飞牛 NAS 上用 Docker 运行 DeepSeek Harness
运维·docker·容器
虎王物联5 小时前
Docker Compose编排物联网平台后端:Nginx+PHP-FPM+EMQX+InfluxDB一键部署实战
物联网·nginx·docker
勇往直前plus8 小时前
Docker PostgreSQL 16 部署要点(Ubuntu 22)
ubuntu·docker·postgresql
angushine9 小时前
Docker部署镜像管理
运维·docker·容器
javachen__10 小时前
Docker一键清理 + 全局限制,告别日志报满
java·docker·容器
java_logo10 小时前
Docker 部署 FalkorDB:轻松搭建属性图数据库与知识图谱平台
数据库·docker·知识图谱·falkordb·轩辕镜像·falkordb部署教程·falkordb部署文档
滨哥GPT14 小时前
Codex修改环境变量后项目还是报错怎么办?.env、配置加载与运行环境排查
docker·ai编程·环境变量·开发环境·codex·env
nuo53420215 小时前
进阶 1 —— Docker 中常见软件的复杂安装
docker·容器
EXI-小洲15 小时前
Docker 容器部署 EMQX|MQTT 消息代理服务安装与配置教程
运维·mqtt·docker·emqx
钝挫力PROGRAMER17 小时前
Windows Docker 环境搭建 GitLab CI/CD 流水线
windows·docker·gitlab·gitlab-runner