Docker知识总结 (三) Docker 常用命令

帮助命令

 docker version # 显示版本信息
 docker info #显示docker的系统信息,包括镜像和容器的数量
 docker --help  #帮助命令

镜像命令

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

在这里插入图片描述
options:

  -a, --all             Show all images (default hides intermediate images)
      --digests         Show digests
  -f, --filter filter   Filter output based on conditions provided
      --format string   Pretty-print images using a Go template
      --no-trunc        Don't truncate output
  -q, --quiet           Only show image IDs

docker search (搜索镜像)

语法:

docker search [OPTIONS] TERM

options:

 -f, --filter filter   Filter output based on conditions provided  
      --format string   Pretty-print search using a Go template   
      --limit int       Max number of search results (default 25)  # 限制搜索的结果数
      --no-trunc        Don't truncate output  #不要截断式输出,输出完整信息

测试:
在这里插入图片描述

[root@VM-4-17-centos /]# docker search --filter=stars=4800 mysql  #搜索srars >= 4800 的镜像
NAME      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql     MySQL is a widely used, open-source relation…   12456     [OK]       
mariadb   MariaDB Server is a high performing open sou…   4800      [OK] 

docker pull 下载镜像

语法:

docker pull [OPTIONS] NAME[:TAG|@DIGEST]

如果不指定tag,默认会下载最新版:

[root@VM-4-17-centos docker]# docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
72a69066d2fe: Pull complete  # 分层下载 docker image的核心  联合文件系统
93619dbc5b36: Pull complete 
99da31dd6142: Pull complete 
626033c43d70: Pull complete 
37d5d7efb64e: Pull complete 
ac563158d721: Pull complete 
d2ba16033dad: Pull complete 
688ba7d5c01a: Pull complete 
00e060b6d11d: Pull complete 
1c04857f594f: Pull complete 
4d7cfa90e6ea: Pull complete 
e0431212d27d: Pull complete 
Digest: sha256:e9027fe4d91c0153429607251656806cc784e914937271037f7738bd5b8e7709 #签名
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest  # 真实地址

下载指定版本:
在这里插入图片描述

docker rmi 删除镜像

语法:

docker rmi [OPTIONS] IMAGE [IMAGE...]

Options:

  -f, --force      Force removal of the image
      --no-prune   Do not delete untagged parents

删除指定的镜像:

[root@VM-4-17-centos docker]# docker rmi -f 镜像id

[root@VM-4-17-centos docker]# docker rmi -f 镜像id 镜像id 镜像id  #删除多个指定的镜像

删除所有的镜像:

[root@VM-4-17-centos docker]# docker rmi -f $(docker images -aq)

docker image COMMAND (管理镜像)

docker image build

容器命令 (有了镜像才可以创建容器)

下载一个镜像:

docker pull centos

docker run (启动容器)

语法:

docker run [OPTIONS] IMAGE 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值