一.帮助命令

docker version #查看docker的版本信息 docker info #查看docker的系统信息,包括镜像和容器的数量 docker 命令 —help #帮助命令(可查看可选的参数) docker COMMAND —help

帮助文档地址:https://docs.docker.com/reference/

二.镜像命令

docker images 查看所有镜像

[root@localhost /]# docker images 镜像仓库源 镜像的标签 镜像的ID 镜像的创建时间 镜像的大小 REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest feb5d9fea6a5 8 months ago 13.3kB

可用参数

-a, —all //显示所有的镜像信息 -q, —quiet //只显示所有镜像的ID

docker search 搜索镜像

[root@localhost ~]# docker search nginx NAME DESCRIPTION STARS OFFICIAL AUTOMATED nginx Official build of Nginx. 16842 [OK]
linuxserver/nginx An Nginx container, brought to you by LinuxS… 168
[root@localhost ~]# docker search —help

Usage: docker search [OPTIONS] TERM

Search the Docker Hub for images

可选参数

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 //搜索收藏数镜像大于3000的 [root@localhost ~]# docker search nginx —filter=STARS=3000 NAME DESCRIPTION STARS OFFICIAL AUTOMATED nginx Official build of Nginx. 16842 [OK]

docker pull 下载镜像

docker pull 镜像名[:tag] 下载镜像 [root@localhost ~]# docker pull mysql Using default tag: latest #如果不写tag,默认就是latest latest: Pulling from library/mysql 72a69066d2fe: Pull complete #分层下载,docker images的核心—联合文件系统 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 pull mysql等价于docker pull docker.io/library/mysql:latest

dokcer rmi 删除镜像

[root@localhost ~]# docker rmi -f 容器ID //删除指定的容器 rm -r删除 i指的是images [root@localhost ~]# docker rmi -f 容器ID 容器ID 容器ID 容器ID //删除多个容器 [root@localhost ~]# docker rmi -f $(docker images -aq) // 使用递归层级删除,全删。

三.容器命令

创建容器前,先下载镜像,有了镜像才能创建容器

docker pull centos //下载镜像

[root@localhost ~]# docker run -it 5d0da3dc9764 /bin/bash //进入容器