Docker镜像的获取和推送

1|0  查找镜像

  查找镜像的方法有主要有两种,一种是在Docker Hub官方网站查找,网址为https://hub.docker.com/

  另一种方法是在命令行界面中通过docker serach <image>来查找相关的镜像。

  docker search命令说明:

docker search [options] TERM --authomated=false Only show automated builds --no-trunc=false Don't truncate output -s,--stars=0 Only displays with at least x stars 最多返回25个结果
View Code

  docker search ubuntu结果:

[root@docker ~]# docker search ubuntu NAME DESCRIPTION STARS OFFICIAL AUTOMATED ubuntu Ubuntu is a Debian-based Linux operating s... 6281 [OK] rastasheep/ubuntu-sshd Dockerized SSH service, built on top of of... 91 [OK] ubuntu-upstart Upstart is an event-based replacement for ... 74 [OK] neurodebian NeuroDebian provides neuroscience research... 37 [OK] ubuntu-debootstrap debootstrap --variant=minbase --components... 30 [OK] 32bit/ubuntu Ubuntu for i386 (32bit) 30 armhf/ubuntu Ubuntu is a Debian-based Linux operating s... 27 nuagebec/ubuntu Simple always updated Ubuntu docker images... 22 [OK] tutum/ubuntu Simple Ubuntu docker images with SSH access 18 ppc64le/ubuntu Ubuntu is a Debian-based Linux operating s... 10 aarch64/ubuntu Ubuntu is a Debian-based Linux operating s... 9 sameersbn/ubuntu 9 [OK] i386/ubuntu Ubuntu is a Debian-based Linux operating s... 7 nimmis/ubuntu This is a docker images different LTS vers... 7 [OK] darksheer/ubuntu Base Ubuntu Image -- Updated hourly 3 [OK] libmesos/ubuntu 3 scaleway/ubuntu Ubuntu image on Scaleway 2 webhippie/ubuntu Docker images for ubuntu 1 [OK] vcatechnology/ubuntu A Ubuntu image that is updated daily 1 [OK] s390x/ubuntu Ubuntu is a Debian-based Linux operating s... 1 konstruktoid/ubuntu Ubuntu base image 0 [OK] smartentry/ubuntu ubuntu with smartentry 0 [OK] ossobv/ubuntu Custom ubuntu image from scratch (based on... 0 defensative/socat-ubuntu 0 [OK] pivotaldata/ubuntu A quick freshening-up of the base Ubuntu d... 0 [root@docker ~]#
View Code

  查找3星以上的ubuntu镜像:

[root@docker ~]# docker search -s 3 ubuntu Flag --stars has been deprecated, use --filter=stars=3 instead NAME DESCRIPTION STARS OFFICIAL AUTOMATED ubuntu Ubuntu is a Debian-based Linux operating s... 6281 [OK] rastasheep/ubuntu-sshd Dockerized SSH service, built on top of of... 91 [OK] ubuntu-upstart Upstart is an event-based replacement for ... 74 [OK] neurodebian NeuroDebian provides neuroscience research... 37 [OK] ubuntu-debootstrap debootstrap --variant=minbase --components... 30 [OK] 32bit/ubuntu Ubuntu for i386 (32bit) 30 armhf/ubuntu Ubuntu is a Debian-based Linux operating s... 27 nuagebec/ubuntu Simple always updated Ubuntu docker images... 22 [OK] tutum/ubuntu Simple Ubuntu docker images with SSH access 18 ppc64le/ubuntu Ubuntu is a Debian-based Linux operating s... 10 aarch64/ubuntu Ubuntu is a Debian-based Linux operating s... 9 sameersbn/ubuntu 9 [OK] i386/ubuntu Ubuntu is a Debian-based Linux operating s... 7 nimmis/ubuntu This is a docker images different LTS vers... 7 [OK] darksheer/ubuntu Base Ubuntu Image -- Updated hourly 3 [OK] libmesos/ubuntu 3 [root@docker ~]#
View Code

2|0  拉取镜像

  镜像通过"docker pull <image>"拉取。

  docker pull命令简单说明:

docker pull [options] NAME[:TAG] -a,--all-tags=false Download all tagged images in the repository
View Code

  拉取ubuntu:14.04镜像:

[root@CentOS7 ~]# docker pull ubuntu:14.04 14.04: Pulling from library/ubuntu cb56c90f0b30: Pull complete 0acc551e5716: Pull complete 8956dcd35143: Pull complete 908242721214: Pull complete b44ff14dd3bb: Pull complete Digest: sha256:5faf6cb681da2be979a177b60d8c18497f962e3d82268c49db6c74008d0c294d Status: Downloaded newer image for ubuntu:14.04 [root@CentOS7 ~]#
View Code

  拉取成功后可以通过docker images查看本地镜像:

[root@CentOS7 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE jie/df_test1 latest cd7c340503bc 3 hours ago 214MB centos/nginx latest e5faa74eeb5d 5 hours ago 401MB php latest 2dbd5ab1d9f5 4 days ago 370MB nginx latest e4e6d42c70b3 5 days ago 107MB centos latest 36540f359ca3 11 days ago 193MB registry latest c2a449c9f834 2 weeks ago 33.2MB mysql latest 44a8e1a5c0b2 3 weeks ago 407MB ubuntu latest d355ed3537e9 3 weeks ago 119MB ubuntu 14.04 4a2820e686c4 3 weeks ago 188MB daocloud.io/daocloud/daocloud-toolset latest bbdc71e950ea 4 months ago 147MB [root@CentOS7 ~]#
View Code

  由于国内的特殊原因,镜像拉取特别慢,很容易下载失败。所以我们可以使用加速器来加速下载,提高下载成功率,现有的比如网易蜂巢加速器、阿里云加速器和daocloud加速器等。可以根据自己喜好选用。

3|0  推送镜像(需要拥有Docker Hub的账号)

  我们自己构建镜像之后可以通过docker push <image>将自己的镜像推送至Docker Hub仓库中,前提是需要有自己的Docker Hub账号。免费的账号只能有一个存储空间,当然Docker Hub支持付费服务,增加可用空间。

[root@docker ~]# docker push jie/df_test1 The push refers to a repository [docker.io/jie/df_test1] sending image list please login prior to push: Username:staryjie Password: Email:fngje0128@163.com Login Successed The push refers to a repository [docker.io/jie/df_test1] f5456bfd299d: Pushing 8f2ab3b3ad55: Waiting 0566c118947e: Preparing 6f9cf951edf5: Waiting 182d2a55830d: Preparing 5a4c2c9a24fc: Preparing cb11ba605400: Waiting
View Code

  等待push完成,上传完成之后即可在Docker Hub中自己的仓库中看到,也可以通过网页搜索查看,如果不想公开,也可以设置镜像为个人,这样别人就无法查看到你的镜像了。


__EOF__

本文作者StaryJie
本文链接https://www.cnblogs.com/jie-fang/p/7207549.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   StaryJie  阅读(1481)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示