Docker 镜像操作

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: Docker 镜像操作



image.png


镜像操作


检索云端镜像


-使用 指令 docker search 关键字  可以检索 (搜索) Docker Hub 官网上提供的所有镜像,之后我们就可以下载需要的镜像

-检索 " mysql ":[root@localhost ~]# docker search mysql

-检索 " redis ":[root@localhost ~]# docker search redis

[root@localhost ~]# docker search mysql
INDEX       NAME                                                             DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/mysql                                                  MySQL is a widely used, open-source relati...   6728      [OK]       
docker.io   docker.io/mariadb                                                MariaDB is a community-developed fork of M...   2141      [OK]       
docker.io   docker.io/mysql/mysql-server                                     Optimized MySQL Server Docker images. Crea...   495                  [OK]
docker.io   docker.io/percona                                                Percona Server is a fork of the MySQL rela...   360       [OK]       
docker.io   docker.io/zabbix/zabbix-server-mysql                             Zabbix Server with MySQL database support       114                  [OK]
docker.io   docker.io/hypriot/rpi-mysql                                      RPi-compatible Docker Image with Mysql          93                   
docker.io   docker.io/zabbix/zabbix-web-nginx-mysql                          Zabbix frontend based on Nginx web-server ...   62                   [OK]
docker.io   docker.io/centurylink/mysql                                      Image containing mysql. Optimized to be li...   60                   [OK]
docker.io   docker.io/1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5   ubuntu-16-nginx-php-phpmyadmin-mysql-5          43                   [OK]
docker.io   docker.io/centos/mysql-57-centos7                                MySQL 5.7 SQL database server                   35                   
docker.io   docker.io/mysql/mysql-cluster                                    Experimental MySQL Cluster Docker images. ...   33                   
docker.io   docker.io/tutum/mysql                                            Base docker image to run a MySQL database ...   32                   
docker.io   docker.io/schickling/mysql-backup-s3                             Backup MySQL to S3 (supports periodic back...   20                   [OK]
docker.io   docker.io/bitnami/mysql                                          Bitnami MySQL Docker Image                      16                   [OK]
docker.io   docker.io/zabbix/zabbix-proxy-mysql                              Zabbix proxy with MySQL database support        15                   [OK]
docker.io   docker.io/linuxserver/mysql                                      A Mysql container, brought to you by Linux...   14                   
docker.io   docker.io/centos/mysql-56-centos7                                MySQL 5.6 SQL database server                   9                    
docker.io   docker.io/circleci/mysql                                         MySQL is a widely used, open-source relati...   6                    
docker.io   docker.io/openshift/mysql-55-centos7                             DEPRECATED: A Centos7 based MySQL v5.5 ima...   6                    
docker.io   docker.io/dsteinkopf/backup-all-mysql                            backup all DBs in a mysql server                4                    [OK]
docker.io   docker.io/mysql/mysql-router                                     MySQL Router provides transparent routing ...   2                    
docker.io   docker.io/openzipkin/zipkin-mysql                                Mirror of https://quay.io/repository/openz...   1                    
docker.io   docker.io/ansibleplaybookbundle/mysql-apb                        An APB which deploys RHSCL MySQL                0                    [OK]
docker.io   docker.io/cloudfoundry/cf-mysql-ci                               Image used in CI of cf-mysql-release            0                    
docker.io   docker.io/cloudposse/mysql                                       Improved `mysql` service with support for ...   0                    [OK]
[root@localhost ~]#


INDEX:索引

NAME:镜像名称

DESCRIPTION:描述

STARS:关注人数,单位为 k

OFFICIAL:是否为官方发布),[ok] 则表示此版本为官方发行版本

AUTOMATED:是否自动配置,[ok] 则表示镜像已经自动配置好了,获取就能直接使用,否则需要自己手动配置

  • 如上所示所有的搜索结果其实都是从 Docker Hub 上获取来的,所以我们自己也可以官网上直接查找


image.png


下载镜像


  • 使用命令:docker pull 镜像名:tag,可以从  Docker Hub 下载指定的镜像,“ :tag ” 不写时默认下载最新版本的镜像,也可以自己指定 tag 从而下载指定版本的镜像,tag 名称可以从 Docker Hub 上自己查看


image.png


[root@localhost ~]# docker search mysql
INDEX       NAME                                                             DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/mysql                                                  MySQL is a widely used, open-source relati...   6728      [OK]       
docker.io   docker.io/mariadb                                                MariaDB is a community-developed fork of M...   2141      [OK]       
docker.io   docker.io/mysql/mysql-server                                     Optimized MySQL Server Docker images. Crea...   495                  [OK]
.......
  • 下载上面 NAME 为 docker.io/msql 镜像为例,使用 " docker pull mysql "即可下载, 前面的 " docker.io/" 可写可不写
  • 如下所示没有提供 "tag" 时, “Using default tag: latest” 表示默认使用 "latest" 版本
  • 下载成功之后,可以使用 " docker images " 查看本地下载好的所有镜像

[root@localhost ~]# docker pull mysql
Using default tag: latest
Trying to pull repository docker.io/library/mysql ... 
latest: Pulling from docker.io/library/mysql
be8881be8156: Pull complete 
c3995dabd1d7: Pull complete 
9931fdda3586: Pull complete 
bb1b6b6eff6a: Pull complete 
a65f125fa718: Pull complete 
2d9f8dd09be2: Pull complete 
37b912cb2afe: Pull complete 
54242fcd8eaa: Pull complete 
0a9d4d211511: Pull complete 
270ae5bd02c2: Pull complete 
9b55b8e72e70: Pull complete 
68083f7985cd: Pull complete 
Digest: sha256:d39a8ab7679df309e7eff6ddba434ad5747cc2a2acee2d7c60d8221c9acedcad
Status: Downloaded newer image for docker.io/mysql:latest
[root@localhost ~]#

如下所示下载的是 docker.io/mysql 5.7 版本的镜像

[root@localhost ~]# docker pull mysql:5.7
Trying to pull repository docker.io/library/mysql ... 
5.7: Pulling from docker.io/library/mysql
be8881be8156: Already exists 
c3995dabd1d7: Already exists 
9931fdda3586: Already exists 
bb1b6b6eff6a: Already exists 
a65f125fa718: Already exists 
2d9f8dd09be2: Already exists 
37b912cb2afe: Already exists 
faf9da46e0cf: Pull complete 
ffcedc9e8600: Pull complete 
6e11f2447e86: Pull complete 
02243b284270: Pull complete 
Digest: sha256:e25e2768e910223db3095c1560aa2255371986b24fbebf4b015bae3cc60b9b34
Status: Downloaded newer image for docker.io/mysql:5.7
[root@localhost ~]#


查看本地镜像


使用命令 docker images 查看本地下载好的所有镜像

[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
docker.io/mysql     5.7                 43b029b6b640        22 hours ago        372 MB
docker.io/mysql     latest              29e0ae3b69b9        22 hours ago        484 MB
[root@localhost ~]#

REPOSITORY :仓库,即下载的镜像名称

TAG:标识,通常为版本号

IMAGE ID:镜像id,删除时根据镜像id进行删除

CRREATED:镜像创建时间

SIZE:镜像大小


删除镜像


使用 docker rmi image-id 命令删除指定的本地镜像

[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
docker.io/mysql     5.7                 43b029b6b640        22 hours ago        372 MB
docker.io/mysql     latest              29e0ae3b69b9        22 hours ago        484 MB
[root@localhost ~]# docker rmi 43b029b6b640
Untagged: docker.io/mysql:5.7
Untagged: docker.io/mysql@sha256:e25e2768e910223db3095c1560aa2255371986b24fbebf4b015bae3cc60b9b34
Deleted: sha256:43b029b6b6406b40f1ba51b069980b5c14b701786830a41ebb489ad3bbf3d928
Deleted: sha256:e8793f33a59faabf48ec2b41dff592700651385fc2d0e4ddc2f7a6efbd0c03c3
Deleted: sha256:06f716d6d745ca2ab39f21f40ba757cbbd93b6189ca47030f4888442b9c2f9ca
Deleted: sha256:0c7d7ee852d955b7ec7353dc367b26ee59c029243e631fc31a53847bffe1852b
Deleted: sha256:35c70a35928fd6ce30c1495b9782b53b69fe0d023c35ad047072e4d7d388a753
[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
docker.io/mysql     latest              29e0ae3b69b9        22 hours ago        484 MB
[root@localhost ~]# docker rmi 29e0ae3b69b9
Untagged: docker.io/mysql:latest
Untagged: docker.io/mysql@sha256:d39a8ab7679df309e7eff6ddba434ad5747cc2a2acee2d7c60d8221c9acedcad
Deleted: sha256:29e0ae3b69b9031ab7d7fd3024057b9441d74c8244e583cfb48697109148ca71
Deleted: sha256:e510a8f0a60462d0280381e93018635f8986c308550dabce0be5249c3402c338
Deleted: sha256:7360cba3164f094ead4b968263cabeed376e7306ca6415c824d63ff7d2c22203
Deleted: sha256:e26ff419bf2626b93431acf08fc734cb88eed5dea413bd05965ba1c51dc9c671
Deleted: sha256:5b9acfeae5767ffb16ef495d68de01b750ac5efcf2af474d695b1fead7c2dabc
Deleted: sha256:3f55b1f8de59e6ba35f38376b4a7ee48ffbb32f23500d16400a18c6d59ad1803
Deleted: sha256:d8a947a6bf007b7b3f857fd157092aa938cc01780175eda5c300847f2758ba6f
Deleted: sha256:424c40c7a715a28330453b0ec3b5afc97caa851a56d365c65a97b583b733b81b
Deleted: sha256:202db300227b8c870b421aa0a0a11b44cb916401ef3a34bcc2a5efcb30a3ea78
Deleted: sha256:20f3dff2c1b6f8409b53e4e203132f7ebb2dfd7dc612d87e4a93302a5a8f5c1a
Deleted: sha256:3131a4917b53634699929d8ff7e2b2bd9469f3f5ab08daf41d1c6b90e0f18b44
Deleted: sha256:9996a15396359708cb2177cfdbe8fcb9f65124142edb9b1d3550f3eb87360676
Deleted: sha256:cdb3f9544e4c61d45da1ea44f7d92386639a052c620d1550376f22f5b46981af
[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
[root@localhost ~]#


相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
5天前
|
存储 安全 持续交付
【Docker 专栏】Docker 镜像的版本控制与管理
【5月更文挑战第9天】本文探讨了Docker镜像版本控制与管理的重要性,包括可重复性、回滚能力、协作开发和持续集成。常用方法有标签、构建参数和版本控制系统。管理策略涉及定期清理、分层管理和镜像仓库。语义化标签、环境变量和配置文件在版本控制中有应用。版本系统与Docker结合能跟踪历史和促进协作。注意点包括优化镜像大小、确保安全性和兼容性。案例分析和未来趋势展示了持续发展的镜像管理技术,为Docker应用的稳定与进步保驾护航。
【Docker 专栏】Docker 镜像的版本控制与管理
|
2天前
|
存储 安全 开发者
如何删除 Docker 镜像、容器和卷?
【5月更文挑战第11天】
13 2
如何删除 Docker 镜像、容器和卷?
|
5天前
|
运维 安全 Docker
【Docker 专栏】Docker 镜像安全扫描与漏洞修复
【5月更文挑战第9天】Docker技术在软件开发和部署中带来便利,但其镜像安全问题不容忽视。本文探讨了Docker镜像安全扫描与漏洞修复,强调了镜像安全对应用和系统的重要性。文中介绍了静态和动态扫描方法,列举了软件漏洞、配置漏洞和恶意软件等常见安全问题,并提到了Clair和Trivy等扫描工具。修复策略包括更新软件、调整配置和重建镜像。此外,加强安全意识、规范镜像制作流程和定期扫描是管理建议。未来,将持续面对新的安全挑战,需持续研究和完善安全技术。
【Docker 专栏】Docker 镜像安全扫描与漏洞修复
|
6天前
|
Java Linux 数据安全/隐私保护
Docker自定义JDK镜像并拉取至阿里云镜像仓库全攻略
Docker自定义JDK镜像并拉取至阿里云镜像仓库全攻略
|
6天前
|
存储 弹性计算 运维
Docker数据集与自定义镜像:构建高效容器的关键要素
Docker数据集与自定义镜像:构建高效容器的关键要素
|
6天前
|
存储 缓存 运维
【Docker 专栏】Docker 镜像的分层存储与缓存机制
【5月更文挑战第8天】Docker 镜像采用分层存储,减少空间占用并提升构建效率。每个镜像由多个层组成,共享基础层(如 Ubuntu)和应用层。缓存机制加速构建和运行,通过检查已有层来避免重复操作。有效管理缓存,如清理无用缓存和控制大小,可优化性能。分层和缓存带来资源高效利用、快速构建和灵活管理,但也面临缓存失效和层管理挑战。理解这一机制对开发者和运维至关重要。
【Docker 专栏】Docker 镜像的分层存储与缓存机制
|
6天前
|
数据库 Docker 容器
【Docker 专栏】使用 Dockerfile 自动化构建 Docker 镜像
【5月更文挑战第8天】Dockerfile是构建Docker镜像的关键,它包含一系列指令,用于描述应用运行环境及所需软件包。通过自动化构建,能提高效率、保证可重复性并提升灵活性。确定基础镜像、安装依赖、设置环境后,执行Dockerfile生成镜像,用于应用程序部署。虽然需要熟悉Docker技术和应用细节,但其带来的益处使其成为现代软件开发和部署的重要工具。
【Docker 专栏】使用 Dockerfile 自动化构建 Docker 镜像
|
7天前
|
缓存 安全 数据安全/隐私保护
【Docker专栏】深入理解Docker镜像的构建与推送
【5月更文挑战第7天】本文介绍了Docker镜像的核心作用及基础概念,包括镜像作为容器模板的特性。文章详细阐述了Dockerfile的编写,例如设置基础镜像、工作目录、安装依赖及定义启动命令。通过`docker build`命令构建镜像,并提示了优化构建过程的技巧。此外,还讲解了如何将镜像推送到远程仓库,包括选择仓库、认证、标签和推送镜像的步骤,以及镜像安全性的考虑,如扫描漏洞和遵循最小权限原则。本文旨在帮助读者掌握Docker镜像的构建与推送,以高效管理容器化应用。
【Docker专栏】深入理解Docker镜像的构建与推送
|
8天前
|
运维 Linux 数据安全/隐私保护
Docker详解(九)——Docker镜像发布
Docker详解(九)——Docker镜像发布
32 2
|
8天前
|
运维 Linux Apache
Docker详解(八)——Docker镜像制作
Docker详解(八)——Docker镜像制作
40 1