Docker Review - docker images 常用命令

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用系列 2核4GB
简介: Docker Review - docker images 常用命令

31ba6d1820c748a98dcc2d94bfddcbbc.png

docker help

[[root@VM-0-7-centos ~]# docker help
Usage:  docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options:
      --config string      Location of client config files (default "/root/.docker")
  -c, --context string     Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context
                           set with "docker context use")
  -D, --debug              Enable debug mode
  -H, --host list          Daemon socket(s) to connect to
  -l, --log-level string   Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
      --tls                Use TLS; implied by --tlsverify
      --tlscacert string   Trust certs signed only by this CA (default "/root/.docker/ca.pem")
      --tlscert string     Path to TLS certificate file (default "/root/.docker/cert.pem")
      --tlskey string      Path to TLS key file (default "/root/.docker/key.pem")
      --tlsverify          Use TLS and verify the remote
  -v, --version            Print version information and quit
Management Commands:
  app*        Docker App (Docker Inc., v0.9.1-beta3)
  builder     Manage builds
  buildx*     Build with BuildKit (Docker Inc., v0.6.1-docker)
  config      Manage Docker configs
  container   Manage containers
  context     Manage contexts
  image       Manage images
  manifest    Manage Docker image manifests and manifest lists
  network     Manage networks
  node        Manage Swarm nodes
  plugin      Manage plugins
  scan*       Docker Scan (Docker Inc., v0.8.0)
  secret      Manage Docker secrets
  service     Manage services
  stack       Manage Docker stacks
  swarm       Manage Swarm
  system      Manage Docker
  trust       Manage trust on Docker images
  volume      Manage volumes
Commands:
  attach      Attach local standard input, output, and error streams to a running container
  build       Build an image from a Dockerfile
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  exec        Run a command in a running container
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  images      List images
  import      Import the contents from a tarball to create a filesystem image
  info        Display system-wide information
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  login       Log in to a Docker registry
  logout      Log out from a Docker registry
  logs        Fetch the logs of a container
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  ps          List containers
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  run         Run a command in a new container
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  search      Search the Docker Hub for images
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  version     Show the Docker version information
  wait        Block until one or more containers stop, then print their exit codes
Run 'docker COMMAND --help' for more information on a command.
To get more help with docker, check out our guides at https://docs.docker.com/go/guides/
[root@VM-0-7-centos ~]#


来看看几个和帮助相关的命令

# 显示docker版本信息
[root@VM-0-7-centos ~]# docker version  
 # 显示docker系统信息,包括镜像和容器数量  
[root@VM-0-7-centos ~]# docker info      
# 帮助信息
[root@VM-0-7-centos ~]# docker COMMAND  --help 
Run 'docker COMMAND --help' for more information on a command.


文档: https://docs.docker.com/engine/reference/commandline/docker/


docker image相关的命令

文档: https://docs.docker.com/engine/reference/commandline/image/


docker images 查看所有本地的主机上的镜像

https://docs.docker.com/engine/reference/commandline/images/

【使用】

docker images [OPTIONS] [REPOSITORY[:TAG]]


4581eb58a952489399d751dcb8788db0.png


【demo】


[root@VM-0-7-centos ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED       SIZE
hello-world   latest    feb5d9fea6a5   12 days ago   13.3kB
# 解释
REPOSITORY   镜像的仓库源
TAG          镜像的标签
IMAGE ID     镜像的id
CREATED      镜像的创建时间
SIZE         镜像的大小

791899fd0a9f44a5bdb69ee7279c8d60.png

docker search 搜索镜像


0c0ce6c436b8407aa9972b0f4aafd878.png


[root@VM-0-7-centos ~]# docker search tomcat
NAME                          DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
tomcat                        Apache Tomcat is an open source implementati…   3146      [OK]
tomee                         Apache TomEE is an all-Apache Java EE certif…   93        [OK]
dordoka/tomcat                Ubuntu 14.04, Oracle JDK 8 and Tomcat 8 base…   58                   [OK]
kubeguide/tomcat-app          Tomcat image for Chapter 1                      31
consol/tomcat-7.0             Tomcat 7.0.57, 8080, "admin/admin"              18                   [OK]
cloudesire/tomcat             Tomcat server, 6/7/8                            15                   [OK]
aallam/tomcat-mysql           Debian, Oracle JDK, Tomcat & MySQL              13                   [OK]
arm32v7/tomcat                Apache Tomcat is an open source implementati…   11
andreptb/tomcat               Debian Jessie based image with Apache Tomcat…   10                   [OK]
rightctrl/tomcat              CentOS , Oracle Java, tomcat application ssl…   7                    [OK]
arm64v8/tomcat                Apache Tomcat is an open source implementati…   6
unidata/tomcat-docker         Security-hardened Tomcat Docker container.      5                    [OK]
amd64/tomcat                  Apache Tomcat is an open source implementati…   3
oobsri/tomcat8                Testing CI Jobs with different names.           2
cfje/tomcat-resource          Tomcat Concourse Resource                       2
jelastic/tomcat               An image of the Tomcat Java application serv…   2
fabric8/tomcat-8              Fabric8 Tomcat 8 Image                          2                    [OK]
picoded/tomcat7               tomcat7 with jre8 and MANAGER_USER / MANAGER…   1                    [OK]
99taxis/tomcat7               Tomcat7                                         1                    [OK]
chenyufeng/tomcat-centos      tomcat基于centos6的镜像                              1                    [OK]
ppc64le/tomcat                Apache Tomcat is an open source implementati…   1
camptocamp/tomcat-logback     Docker image for tomcat with logback integra…   1                    [OK]
s390x/tomcat                  Apache Tomcat is an open source implementati…   0
softwareplant/tomcat          Tomcat images for jira-cloud testing            0                    [OK]
secoresearch/tomcat-varnish   Tomcat and Varnish 5.0                          0                    [OK]
[root@VM-0-7-centos ~]#
# 可选项,通过镜像来过滤
  -f, --filter=STARS=3000   # 搜索出来的镜像就是STARS大于3000的 
[root@VM-0-7-centos ~]# docker search tomcat --filter=STARS=3000
NAME      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
tomcat    Apache Tomcat is an open source implementati…   3146      [OK]
[root@VM-0-7-centos ~]#

22e697200a0b4909bfe6b367e94702ba.png


docker pull 下载镜像



5e466218bff0479f9afe90b103bca41c.png

c448fb191f904161855e5269a7ee0a1b.png

[root@VM-0-7-centos ~]# docker search mysql
NAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql                             MySQL is a widely used, open-source relation…   11507     [OK]
mariadb                           MariaDB Server is a high performing open sou…   4367      [OK]
mysql/mysql-server                Optimized MySQL Server Docker images. Create…   850                  [OK]
percona                           Percona Server is a fork of the MySQL relati…   557       [OK]
phpmyadmin                        phpMyAdmin - A web interface for MySQL and M…   336       [OK]
centos/mysql-57-centos7           MySQL 5.7 SQL database server                   91
mysql/mysql-cluster               Experimental MySQL Cluster Docker images. Cr…   88
centurylink/mysql                 Image containing mysql. Optimized to be link…   59                   [OK]
databack/mysql-backup             Back up mysql databases to... anywhere!         51
prom/mysqld-exporter                                                              42                   [OK]
deitch/mysql-backup               REPLACED! Please use http://hub.docker.com/r…   41                   [OK]
tutum/mysql                       Base docker image to run a MySQL database se…   35
linuxserver/mysql                 A Mysql container, brought to you by LinuxSe…   31
schickling/mysql-backup-s3        Backup MySQL to S3 (supports periodic backup…   31                   [OK]
mysql/mysql-router                MySQL Router provides transparent routing be…   23
centos/mysql-56-centos7           MySQL 5.6 SQL database server                   20
arey/mysql-client                 Run a MySQL client from a docker container      18                   [OK]
fradelg/mysql-cron-backup         MySQL/MariaDB database backup using cron tas…   16                   [OK]
yloeffler/mysql-backup            This image runs mysqldump to backup data usi…   7                    [OK]
openshift/mysql-55-centos7        DEPRECATED: A Centos7 based MySQL v5.5 image…   6
devilbox/mysql                    Retagged MySQL, MariaDB and PerconaDB offici…   3
jelastic/mysql                    An image of the MySQL database server mainta…   2
ansibleplaybookbundle/mysql-apb   An APB which deploys RHSCL MySQL                2                    [OK]
widdpim/mysql-client              Dockerized MySQL Client (5.7) including Curl…   1                    [OK]
centos/mysql-80-centos7           MySQL 8.0 SQL database server                   1
# 下载一个mysql的镜像,默认下载最新的镜像
[root@VM-0-7-centos ~]# docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
07aded7c29c6: Pull complete
f68b8cbd22de: Pull complete
30c1754a28c4: Pull complete
1b7cb4d6fe05: Pull complete
79a41dc56b9a: Pull complete
00a75e3842fb: Pull complete
b36a6919c217: Pull complete
635b0b84d686: Pull complete
6d24c7242d02: Pull complete
5be6c5edf16f: Pull complete
cb35eac1242c: Pull complete
a573d4e1c407: Pull complete
Digest: sha256:4fcf5df6c46c80db19675a5c067e737c1bc8b0e78e94e816a778ae2c6577213d
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]#
# 下载指定版本的镜像
[root@VM-0-7-centos ~]# docker pull mysql:5.7
5.7: Pulling from library/mysql
07aded7c29c6: Already exists
f68b8cbd22de: Already exists
30c1754a28c4: Already exists
1b7cb4d6fe05: Already exists
79a41dc56b9a: Already exists
00a75e3842fb: Already exists
b36a6919c217: Already exists
5e11fe494f45: Pull complete
9c7de1f889a7: Pull complete
cf6a13d05a76: Pull complete
fc5aa81f393a: Pull complete
Digest: sha256:360c7488c2b5d112804a74cd272d1070d264eef4812d9a9cc6b8ed68c3546189
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]#
# 查看下载的所有镜像
[root@VM-0-7-centos ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED       SIZE
mysql         5.7       9f35042c6a98   8 days ago    448MB
mysql         latest    2fe463762680   8 days ago    514MB
hello-world   latest    feb5d9fea6a5   12 days ago   13.3kB
[root@VM-0-7-centos ~]#

5bd5b27b35d1425584994bc33d181641.png


docker rmi 删除镜像


eb5e67a650af44f6a07052d2e2832d53.png

ad2f80ef64634f8d95753ac94e98cb60.png


[root@VM-0-7-centos ~]# docker rmi  9f35042c6a98
Untagged: mysql:5.7
Untagged: mysql@sha256:360c7488c2b5d112804a74cd272d1070d264eef4812d9a9cc6b8ed68c3546189
Deleted: sha256:9f35042c6a98363147ae456147643a3d14c484640f13f4ab207cf2c296839baf
Deleted: sha256:69a5732b5b989ff688326db6354b0f50165a71cfe7579b285054b561fb3c5143
Deleted: sha256:448b1f9cb8f126363f0e809e0e450c493ca1e725715127a258c5346fcae7cd8a
Deleted: sha256:4064542818b4bf92f293da870d3ea1413a20d0c1a83f72917c50986880255338
Deleted: sha256:8ca7f5e08bac7aa39cf9b8b79bf40669373b9aed45ec76eb0fa55109350b6672
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED       SIZE
mysql         latest    2fe463762680   8 days ago    514MB
hello-world   latest    feb5d9fea6a5   12 days ago   13.3kB
[root@VM-0-7-centos ~]#

【批量操作】

## 删除所有镜像
[root@VM-0-7-centos ~]# docker rmi -f $(docker images -aq)
[root@VM-0-7-centos ~]# docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
[root@VM-0-7-centos ~]## 
# 删除多个镜像
[root@VM-0-7-centos ~]# docker rmi -f 镜像id 镜像id 镜像id
[root@VM-0-7-centos ~]# docker rmi -f $(docker images -aq)
Untagged: mysql:latest
Untagged: mysql@sha256:4fcf5df6c46c80db19675a5c067e737c1bc8b0e78e94e816a778ae2c6577213d
Deleted: sha256:2fe4637626805dc6df98d3dc17fa9b5035802dcbd3832ead172e3145cd7c07c2
Deleted: sha256:e00bdaa10222919253848d65585d53278a2f494ce8c6a445e5af0ebfe239b3b5
Deleted: sha256:83411745a5928b2a3c2b6510363218fb390329f824e04bab13573e7a752afd50
Deleted: sha256:e8e521a71a92aad623b250b0a192a22d54ad8bbeb943f7111026041dce20d94f
Deleted: sha256:024ee0ef78b28663bc07df401ae3a258ae012bd5f37c2960cf638ab4bc04fafd
Deleted: sha256:597139ec344c8cb622127618ae21345b96dd23e36b5d04b071a3fd92d207a2c0
Deleted: sha256:28909b85bd680fc47702edb647a06183ae5f3e3020f44ec0d125bf75936aa923
Deleted: sha256:4e007ef1e2a3e1e0ffb7c0ad8c9ea86d3d3064e360eaa16e7c8e10f514f68339
Deleted: sha256:b01d7bbbd5c0e2e5ae10de108aba7cd2d059bdd890814931f6192c97fc8aa984
Deleted: sha256:d98a368fc2299bfa2c34cc634fa9ca34bf1d035e0cca02e8c9f0a07700f18103
Deleted: sha256:95968d83b58ae5eec87e4c9027baa628d0e24e4acebea5d0f35eb1b957dd4672
Deleted: sha256:425adb901baf7d6686271d2ce9d42b8ca67e53cffa1bc05622fd0226ae40e9d8
Deleted: sha256:476baebdfbf7a68c50e979971fcd47d799d1b194bcf1f03c1c979e9262bcd364
Untagged: hello-world:latest
Untagged: hello-world@sha256:9ade9cc2e26189a19c2e8854b9c8f1e14829b51c55a630ee675a5a9540ef6ccf
Deleted: sha256:feb5d9fea6a5e9606aa995e879d862b825965ba48de054caab5ef356dc6b3412
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]# docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
[root@VM-0-7-centos ~]#


其他…



46fe6fcadcce45db9f5c05c19988a439.png

https://docs.docker.com/engine/reference/commandline/images/


fda23197c2a148a2b3109a45789e8c10.png


相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
2月前
|
安全 Docker 容器
|
2月前
|
网络安全 数据安全/隐私保护 Docker
|
10天前
|
NoSQL 关系型数据库 MySQL
《docker高级篇(大厂进阶):4.Docker网络》包括:是什么、常用基本命令、能干嘛、网络模式、docker平台架构图解
《docker高级篇(大厂进阶):4.Docker网络》包括:是什么、常用基本命令、能干嘛、网络模式、docker平台架构图解
109 56
《docker高级篇(大厂进阶):4.Docker网络》包括:是什么、常用基本命令、能干嘛、网络模式、docker平台架构图解
|
17天前
|
监控 NoSQL 时序数据库
《docker高级篇(大厂进阶):7.Docker容器监控之CAdvisor+InfluxDB+Granfana》包括:原生命令、是什么、compose容器编排,一套带走
《docker高级篇(大厂进阶):7.Docker容器监控之CAdvisor+InfluxDB+Granfana》包括:原生命令、是什么、compose容器编排,一套带走
156 77
|
14天前
|
关系型数据库 MySQL Docker
《docker高级篇(大厂进阶):5.Docker-compose容器编排》包括是什么能干嘛去哪下、Compose核心概念、Compose使用三个步骤、Compose常用命令、Compose编排微服务
《docker高级篇(大厂进阶):5.Docker-compose容器编排》包括是什么能干嘛去哪下、Compose核心概念、Compose使用三个步骤、Compose常用命令、Compose编排微服务
75 24
|
1月前
|
Java 应用服务中间件 Linux
【Docker容器化技术】docker安装与部署、常用命令、容器数据卷、应用部署实战、Dockerfile、服务编排docker-compose、私有仓库
本文主要讲解了Docker的安装与部署、常用命令、容器数据卷、应用部署实战、Dockerfile、服务编排docker-compose、私有仓库以及Docker容器虚拟化与传统虚拟机比较。
775 12
【Docker容器化技术】docker安装与部署、常用命令、容器数据卷、应用部署实战、Dockerfile、服务编排docker-compose、私有仓库
|
16天前
|
关系型数据库 MySQL Docker
《docker高级篇(大厂进阶):5.Docker-compose容器编排》包括是什么能干嘛去哪下、Compose核心概念、Compose使用三个步骤、Compose常用命令、Compose编排微服务
《docker高级篇(大厂进阶):5.Docker-compose容器编排》包括是什么能干嘛去哪下、Compose核心概念、Compose使用三个步骤、Compose常用命令、Compose编排微服务
94 6
|
3月前
|
Linux Docker 容器
Docker操作 :容器命令
Docker操作 (四)
208 56
|
2月前
|
存储 监控 安全
|
2月前
|
存储 关系型数据库 MySQL

热门文章

最新文章