Docker Hub简单使用

2023年 7月 16日 68.9k 0

Docker hub仓库使用

准备工作:

​ 起先,需要在https://hub.docker.com/注册一个用户

演示一次将镜像上传到docker hub的过程

pull一个镜像

首先需要一个镜像

[root@localhost ~]# docker pull benyoo/alpine:3.4.20160812  
3.4.20160812: Pulling from benyoo/alpine

e110a4a17941: Already exists 
Digest: sha256:41250fea2bc5dfdc204d54e4d2108aae7a452876bed359ae277983aea4ae3e02
Status: Downloaded newer image for benyoo/alpine:3.4.20160812

将镜像run起来

[root@localhost ~]# docker run --name myalpine -it benyoo/alpine:3.4.20160812 /bin/bash
bash-4.3# exit

commit

现在我将容器commit

[root@gitlab nginx]# docker commit -m "v1" f8ac81a9f98c marksugar/nginx:8.30
sha256:e50a274c5823651858d56763d02e2cd843006a61f9ff3f97535eb7dd8d17db2f
[root@gitlab nginx]# docker images
REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
marksugar/nginx           8.30                e50a274c5823        6 seconds ago       13.77 MB

登录docker hub

commit完成后,先登录

[root@localhost ~]# 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: marksugar
Password: 
Login Succeeded

commit完成后在images中会出现一个新的

[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
marksugar/alpine    latest              07a4ff4374e1        5 seconds ago       11.54 MB
marksugar/nginx     8.30                e50a274c5823        10 hours ago        13.77 MB
benyoo/alpine       3.4.20160812        0ae37ed604b2        2 weeks ago         11.54 MB
nginx               latest              0d409d33b27e        3 months ago        182.7 MB

开始上传

开始push

[root@localhost ~]# docker push marksugar/alpine
The push refers to a repository [docker.io/marksugar/alpine]
dbe4e1a4c160: Pushed 
93d40cd73394: Mounted from marksugar/nginx 
4fe15f8d0ae6: Mounted from marksugar/nginx 
latest: digest: sha256:5ae1b32053247f3d251fe5ee56aa817d330cb007603272985a0aab0b79a4c9b3 size: 946
[root@localhost ~]# 

上传完成后在docker hub中会出现一个marksugar/alpine,现在将他pull下来

[root@gitlab conf]# docker pull marksugar/alpine
Using default tag: latest
latest: Pulling from marksugar/alpine

e110a4a17941: Already exists 
92c6475c18dd: Pull complete 
Digest: sha256:5ae1b32053247f3d251fe5ee56aa817d330cb007603272985a0aab0b79a4c9b3
Status: Downloaded newer image for marksugar/alpine:latest

在查看marksugar/alpine

[root@gitlab conf]# docker images
REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
marksugar/nginx           1.0.1               80290b27fdc1        31 minutes ago      229.5 MB
marksugar/nginx           8.31                7046101b038d        57 minutes ago      229.6 MB
marksugar/alpine          latest              07a4ff4374e1        7 hours ago         11.54 MB
marksugar/nginx           8.33                ba2cd7b6fa62        15 hours ago        13.77 MB
centos7                   7.2.1511            ad31b9ab4442        39 hours ago        245.3 MB
svn                       1                   5d8633134e71        41 hours ago        288.7 MB
benyoo/alpine             3.4.20160812        0ae37ed604b2        2 weeks ago         11.54 MB
registry                  latest              c6c14b3960bd        4 weeks ago         33.28 MB
docker/compose            1.8.0               89188432ef03        4 weeks ago         59.09 MB
hello-world               latest              c54a2cc56cbb        8 weeks ago         1.848 kB
kriation/centos7          latest              e8630f595772        3 months ago        198.4 MB
new1                      latest              e8630f595772        3 months ago        198.4 MB
10.10.239.222:5000/new2   latest              e8630f595772        3 months ago        198.4 MB
[root@gitlab conf]# 

请输入图片描述

相关文章

LeaferJS 1.0 重磅发布:强悍的前端 Canvas 渲染引擎
10分钟搞定支持通配符的永久有效免费HTTPS证书
300 多个 Microsoft Excel 快捷方式
一步步配置基于kubeadmin的kubevip高可用
istio全链路传递cookie和header灰度
REST Web 服务版本控制

发布评论