Docker镜像命令

帮助命令

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

镜像命令

docker images 查看所有镜像

[root@localhost ~]# docker images
REPOSITORY    TAG                IMAGE ID       CREATED         SIZE
mkjz/centos   latest             ad89ab41f5d7   40 hours ago    304MB
tomcat        latest             921ef208ab56   2 days ago      668MB
mysql         latest             95db2e2bd882   4 days ago      514MB
sbwml/alist   latest             ae685d913f61   13 days ago     28.9MB
redis         5.0.9-alpine3.11   3661c84ee9d0   15 months ago   29.8MB
REPOSITORY 仓库源
TAG 版本信息
IMAGE ID 镜像ID
CREATED 镜像创建时间
SIZE 镜像大小

# 可选项
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 只显示镜像ID

docker search 搜索镜像

[root@localhost ~]# docker search mysql
NAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql                             MySQL is a widely used, open-source relation…   11158     [OK]       
mariadb                           MariaDB Server is a high performing open sou…   4235      [OK]       
mysql/mysql-server                Optimized MySQL Server Docker images. Create…   830                  [OK]
percona                           Percona Server is a fork of the MySQL relati…   548       [OK]       
phpmyadmin                        phpMyAdmin - A web interface for MySQL and M…   277       [OK]       
centos/mysql-57-centos7           MySQL 5.7 SQL database server                   90                   

# 可选项
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
--filter=STARS=3000 # 搜索出来的STARS是大于3000的

docker pull 下载镜像

[root@localhost ~]# docker pull redis
Using default tag: latest # 如果不写Tag 默认为最新版本
latest: Pulling from library/redis # 分层下载,docker联合文件系统
33847f680f63: Pull complete 
26a746039521: Pull complete 
18d87da94363: Pull complete 
5e118a708802: Pull complete 
ecf0dbe7c357: Pull complete 
46f280ba52da: Pull complete 
Digest: sha256:cd0c68c5479f2db4b9e2c5fbfdb7a8acb77625322dd5b474578515422d3ddb59
Status: Downloaded newer image for redis:latest
docker.io/library/redis:latest # 真实地址

docker rmi 删除镜像

[root@localhost ~]# docker rmi redis # 删除指定容器
docker rmi 容器名 容器名 容器名 # 删除多个容器
docker rmi $(docker images -aq) # 删除全部容器

docker commit 提交镜像

docker commit 提交容器成为一个新的副本
docker commit -m='提交描述的信息' -a='作者' 容器名称 目标镜像名:[tag]