目录

Docker镜像基本命令

帮助命令

    docker version #显示docker的版本信息
    docker info #显示docker的系统信息
    docker 命令 --help #帮助命令

镜像命令

docker images #查看所有本机是上面的镜像
mac@MacdeMacBook-Pro ~ % docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
alpine/git    latest    7660bb3edeb5   2 days ago     25.1MB
hello-world   latest    d1165f221234   2 months ago   13.3kB
#解释
REPOSITORY 镜像的仓库源
TAG 镜像的标签
IMAGE ID 镜像的Id
CREATED 镜像的创建时间
SIZE  镜像的大小
# 可选项
--all , -a      Show all images (default hides intermediate images) 
--digests       Show digests
--filter , -f       Filter output based on conditions provided
--format        Pretty-print images using a Go template
--no-trunc      Don't truncate output
--quiet , -q        Only show image IDs

docker search搜索镜像

mac@MacdeMacBook-Pro ~ % docker search redis
NAME                             DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
redis                            Redis is an open source key-value store that…   9466      [OK]       
bitnami/redis                    Bitnami Redis Docker Image                      181                  [OK]
grokzen/redis-cluster            Redis cluster 3.0, 3.2, 4.0, 5.0, 6.0, 6.2 
# 可选项
--filter=STARS=3000 搜索start数字大于3000的
mac@MacdeMacBook-Pro ~ % docker search redis --filter=STARS=3000 
NAME      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
redis     Redis is an open source key-value store that…   9466      [OK]

docker pull 下载镜像

#下载镜像 docker pull 镜像名[:tag]
mac@MacdeMacBook-Pro ~ % docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
69692152171a: Pull complete  #分层下载  docker image的核心 联合文件系统
1651b0be3df3: Pull complete 
951da7386bc8: Pull complete 
0f86c95aa242: Pull complete 
37ba2d8bd4fe: Pull complete 
6d278bb05e94: Pull complete 
497efbd93a3e: Pull complete 
f7fddf10c2c2: Pull complete 
16415d159dfb: Pull complete 
0e530ffc6b73: Pull complete 
b0a4a1a77178: Pull complete 
cd90f92aa9ef: Pull complete 
Digest: sha256:d50098d7fcb25b1fcb24e2d3247cae3fc55815d64fec640dc395840f8fa80969 #签名
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest

docker rmi 删除镜像

mac@MacdeMacBook-Pro ~ % docker rmi -f 镜像id  #删除指定镜像
mac@MacdeMacBook-Pro ~ % docker rmi -f 镜像id1 镜像id3 镜像id2 #删除多个镜像
mac@MacdeMacBook-Pro ~ % docker rmi -f $(docker images -aq) #删除全部镜像