Docker (三) 镜像的基础命令

Docker 的常用命令

> docker version           #显示docker 版本
> docker info              #显示docker的系统信息,包括镜像和容器的数量
> docker                   #帮助命令
帮助文档的地址:  https://docs.docker.com/reference/ 

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

docker images 
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              bf756fb1ae65        11 months ago       13.3kB

#注释:
REPOSITORY   镜像的仓库源
TAG          镜像的标签
IMAGE ID     镜像的ID  
CREATED      镜像的创建时间
SIZE         镜像的大小

#可选项
-a  , --all     #列出所有的镜像
-q , --quiet    #只显示镜像的ID 

docker search 搜索镜像

[root@localhost /]# docker search mysql 
NAME                              DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
mysql                             MySQL is a widely used, open-source relation…   10202               [OK]                
mariadb                           MariaDB is a community-developed fork of MyS…   3753                [OK]                
mysql/mysql-server                Optimized MySQL Server Docker images. Create…   746                                     [OK]
percona                           Percona Server is a fork of the MySQL relati…   511                 [OK]                
centos/mysql-57-centos7           MySQL 5.7 SQL database server                   86                                      
mysql/mysql-cluster               Experimental MySQL Cluster Docker images. Cr…   78                                      
centurylink/mysql                 Image containing mysql. Optimized to be link…   60                                      [OK]
bitnami/mysql                     Bitnami MySQL Docker Image                      47                                      [OK]
deitch/mysql-backup               REPLACED! Please use http://hub.docker.com/r…   41                                      [OK]

#可选项,通过收藏去过滤

--filter=STARS=3000      #搜索出来的镜像STARS大于3000的! 
[root@localhost /]# docker search mysql --filter=STARS=3000
NAME                DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
mysql               MySQL is a widely used, open-source relation…   10202               [OK]                
mariadb             MariaDB is a community-developed fork of MyS…   3753                [OK]  
              
--filter=STARS=5000
[root@localhost /]# docker search mysql --filter=STARS=5000
NAME                DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
mysql               MySQL is a widely used, open-source relation…   10202               [OK]              

docker pull 下载镜像

#下载镜像docker pull 镜像名[:tag]
[root@localhost /]# docker pull mysql 
Using default tag: latest     #如果不写tag,默认latest(最后一个版本)
latest: Pulling from library/mysql    
852e50cd189d: Pull complete   #分层下载,docker  image的核心,联合文件系统
29969ddb0ffb: Pull complete 
a43f41a44c48: Pull complete 
5cdd802543a3: Pull complete 
b79b040de953: Pull complete 
938c64119969: Pull complete 
7689ec51a0d9: Pull complete 
a880ba7c411f: Pull complete 
984f656ec6ca: Pull complete 
9f497bce458a: Pull complete 
b9940f97694b: Pull complete 
2f069358dc96: Pull complete 
Digest: sha256:4bb2e81a40e9d0d59bd8e3dc2ba5e1f2197696f6de39a91e90798dd27299b093
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest    #真实地址

#等价于它
docker pull mysql 
docker pull  docker.io/library/mysql:latest 

#指定版本下载:
[root@localhost /]# docker pull mysql:5.7
5.7: Pulling from library/mysql
852e50cd189d: Already exists 
29969ddb0ffb: Already exists 
a43f41a44c48: Already exists 
5cdd802543a3: Already exists 
b79b040de953: Already exists 
938c64119969: Already exists 
7689ec51a0d9: Already exists 
36bd6224d58f: Pull complete 
cab9d3fa4c8c: Pull complete 
1b741e1c47de: Pull complete 
aac9d11987ac: Pull complete 
Digest: sha256:8e2004f9fe43df06c3030090f593021a5f283d028b5ed5765cc24236c2c4d88e
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7

docker rmi 删除镜像!

[root@localhost /]# docker rmi -f   镜像id                #删除指定的容器
[root@localhost /]# docker rmi -f   镜像id  容器id 容器id  #删除多个镜像
[root@localhost /]# docker rmi  -f $(docker images -aq)  #删除全部镜像

一切有关镜像命令,可选参数皆可在官方文档及 --help 查看到!

整理于
https://www.bilibili.com/video/BV1og4y1q7M4?p=9

欢迎 增改纠正提醒!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值