docker(镜像命令)
接上篇:docker(帮助启动类命令)
1、docker images:列出本地主机上的镜像
[root@hadoop100 docker]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest feb5d9fea6a5 21 months ago 13.3kB
REPOSITORY:镜像的仓库源
TAG;镜像的标签版本号
IMAGE ID:镜像ID
CREATED:镜像创建时间
SIZE:镜像大小
同一个仓库源可以有不同的TAG(版本),我们使用REPOSITORY:TAG来定义不同的镜像,如果不指定一个TAG(版本),docker将默认使用latest(最新版);
-- -q:只显示镜像ID -- -a:列出本地所有镜像(含历史映像层) [root@hadoop100 docker]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest feb5d9fea6a5 21 months ago 13.3kB [root@hadoop100 docker]# docker images -a REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest feb5d9fea6a5 21 months ago 13.3kB [root@hadoop100 docker]# docker images -q feb5d9fea6a5 [root@hadoop100 docker]# docker images -qa feb5d9fea6a5
2、docker search 镜像名称:在远程仓库中搜索某个镜像
2.1、docker search --limit 5 redis 只显示最前面的5条
-- --limit 数字N:列举出N个镜像,默认25个 [root@hadoop100 docker]# docker search redis NAME DESCRIPTION STARS OFFICIAL AUTOMATED redis Redis is an open source key-value store that… 12192 [OK] bitnami/redis Bitnami Redis Docker Image 259 [OK] redislabs/redisinsight RedisInsight - The GUI for Redis 88 redis/redis-stack redis-stack installs a Redis server with add… 57 redislabs/redisearch Redis With the RedisSearch module pre-loaded… 56 redislabs/rejson RedisJSON - Enhanced JSON data type processi… 53 redis/redis-stack-server redis-stack-server installs a Redis server w… 47 redislabs/redismod An automated build of redismod - latest Redi… 41 [OK] redislabs/redis Clustered in-memory database engine compatib… 38 redislabs/redisgraph A graph database module for Redis 26 [OK] redislabs/rebloom A probablistic datatypes module for Redis 23 [OK] redislabs/redistimeseries A time series database module for Redis 12 redislabs/operator 7 redislabs/redis-py 5 redislabs/redisai 5 redislabs/redisgears An automated build of RedisGears 4 redislabs/redis-webcli A tiny Flask app to provide access to Redis … 3 [OK] redislabs/redisml A Redis module that implements several machi… 3 [OK] redislabs/k8s-controller 2 redislabs/operator-internal This repository contains pre-released versio… 1 redislabs/memtier_benchmark Docker image to run memtier_benchmark 0 redislabs/olmtest Test artefact for OLM CSV 0 redislabs/k8s-controller-internal 0 redislabs/olm-bundle 0 redislabs/ng-redis-raft Redis with redis raft module 0 [root@hadoop100 docker]# docker search --limit 5 redis NAME DESCRIPTION STARS OFFICIAL AUTOMATED redis Redis is an open source key-value store that… 12192 [OK] redislabs/redisinsight RedisInsight - The GUI for Redis 88 redislabs/redisearch Redis With the RedisSearch module pre-loaded… 56 redislabs/redis Clustered in-memory database engine compatib… 38 redislabs/rebloom A probablistic datatypes module for Redis 23 [OK] [root@hadoop100 docker]#
NAME:镜像名称
DESCRIPTION:描述
STARS:点赞数
OFFICIAL:是否官方认证
AUTOMATE:是否自动构建
3、docker pull 镜像名称:在远程仓库拉取某个镜像
docker pull 镜像名称:默认拉取latest(最新版)
docker pull 镜像名称:TAG:拉取当前TAG版本的镜像
-- 当前docker本机上的镜像 [root@hadoop100 docker]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest feb5d9fea6a5 21 months ago 13.3kB -- 搜索docker远程仓库 redis镜像,只列出5条 [root@hadoop100 docker]# docker search --limit 5 redis NAME DESCRIPTION STARS OFFICIAL AUTOMATED redis Redis is an open source key-value store that… 12192 [OK] redislabs/redisinsight RedisInsight - The GUI for Redis 88 redislabs/redisearch Redis With the RedisSearch module pre-loaded… 56 redislabs/redis Clustered in-memory database engine compatib… 38 redislabs/rebloom A probablistic datatypes module for Redis 23 [OK] -- 拉取(下载)redis镜像,不写版本号则是最新版 latest [root@hadoop100 docker]# docker pull redis Using default tag: latest latest: Pulling from library/redis a2abf6c4d29d: Pull complete c7a4e4382001: Pull complete 4044b9ba67c9: Pull complete c8388a79482f: Pull complete 413c8bb60be2: Pull complete 1abfd3011519: Pull complete Digest: sha256:db485f2e245b5b3329fdc7eff4eb00f913e09d8feb9ca720788059fdc2ed8339 Status: Downloaded newer image for redis:latest docker.io/library/redis:latest -- 当前docker本机上多了一个TAG:latest(最新版)的redis镜像 [root@hadoop100 docker]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE redis latest 7614ae9453d1 18 months ago 113MB hello-world latest feb5d9fea6a5 21 months ago 13.3kB -- 拉取redis镜像并指定版本号 TAG:6.0.8 [root@hadoop100 docker]# docker pull redis:6.0.8 6.0.8: Pulling from library/redis bb79b6b2107f: Pull complete 1ed3521a5dcb: Pull complete 5999b99cee8f: Pull complete 3f806f5245c9: Pull complete f8a4497572b2: Pull complete eafe3b6b8d06: Pull complete Digest: sha256:21db12e5ab3cc343e9376d655e8eabbdbe5516801373e95a8a9e66010c5b8819 Status: Downloaded newer image for redis:6.0.8 docker.io/library/redis:6.0.8 -- 当前docker本机上多了一个TAG:6.0.8 的redis镜像 [root@hadoop100 docker]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE redis latest 7614ae9453d1 18 months ago 113MB hello-world latest feb5d9fea6a5 21 months ago 13.3kB redis 6.0.8 16ecd2772934 2 years ago 104MB [root@hadoop100 docker]#
4、docker system df:查看镜像、容器、数据卷所占用的空间
[root@hadoop100 docker]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE redis latest 7614ae9453d1 18 months ago 113MB hello-world latest feb5d9fea6a5 21 months ago 13.3kB redis 6.0.8 16ecd2772934 2 years ago 104MB [root@hadoop100 docker]# docker system df TYPE TOTAL ACTIVE SIZE RECLAIMABLE Images 3 1 216.9MB 216.9MB (99%) Containers 3 0 0B 0B Local Volumes 0 0 0B 0B Build Cache 0 0 0B 0B
Images:镜像
Containers:容器
Local Volumes:本地卷
Build Cache:构建缓存
TOTAL:条数
ACTIVE:运行中,活跃的
SIZE:大小
RECLAIMABLE:可回收
5、docker rmi 镜像名称ID:删除镜像
docker rmi 镜像名称或者镜像ID:删除单个镜像
docker rmi -f 镜像名称或者镜像ID:强制删除单个镜像
docker rmi -f 镜像;TAG 镜像:TAG:强制删除多个镜像
docker rmi -f $(docker images -qa):强制删除所有镜像
-- 普通删除 hello-world镜像 [root@hadoop100 docker]# docker rmi hello-world Error response from daemon: conflict: unable to remove repository reference "hello-world" (must force) - container 782d1109ec08 is using its referenced image feb5d9fea6a5 -- -f 强制删除 [root@hadoop100 docker]# docker rmi -f hello-world Untagged: hello-world:latest Untagged: hello-world@sha256:aa0cc8055b82dc2509bed2e19b275c8f463506616377219d9642221ab53cf9fe Deleted: sha256:feb5d9fea6a5e9606aa995e879d862b825965ba48de054caab5ef356dc6b3412 [root@hadoop100 docker]# docker rmi -f 7614ae9453dl Error: No such image: 7614ae9453dl -- hello-world镜像已经被删除 [root@hadoop100 docker]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE redis latest 7614ae9453d1 18 months ago 113MB redis 6.0.8 16ecd2772934 2 years ago 104MB -- 使用IMAGE ID删除镜像 [root@hadoop100 docker]# docker rmi -f 16ecd2772934 Untagged: redis:6.0.8 Untagged: redis@sha256:21db12e5ab3cc343e9376d655e8eabbdbe5516801373e95a8a9e66010c5b8819 Deleted: sha256:16ecd277293476392b71021cdd585c40ad68f4a7488752eede95928735e39df4 Deleted: sha256:3746030fff867eb26a0338ad9d3ab832e6c19c7dc008090bcfa95c7b9f16f505 Deleted: sha256:1274ec54ad17d15ec95d2180cb1f791057e86dfcdfcc18cd58610a920e145945 Deleted: sha256:18d156147e54edec9a927080fdc0a53c4a8814b0c717b36dc62e637363c1a98d Deleted: sha256:a8f09c4919857128b1466cc26381de0f9d39a94171534f63859a662d50c396ca Deleted: sha256:2ae5fa95c0fce5ef33fbb87a7e2f49f2a56064566a37a83b97d3f668c10b43d6 Deleted: sha256:d0fe97fa8b8cefdffcef1d62b65aba51a6c87b6679628a2b50fc6a7a579f764c -- redis:6.0.8镜像被删除 [root@hadoop100 docker]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE redis latest 7614ae9453d1 18 months ago 113MB [root@hadoop100 docker]#
-- 删除多个镜像 [root@hadoop100 docker]# docker rmi -f redis redis:6.0.8 Untagged: redis:latest Untagged: redis@sha256:db485f2e245b5b3329fdc7eff4eb00f913e09d8feb9ca720788059fdc2ed8339 Deleted: sha256:7614ae9453d1d87e740a2056257a6de7135c84037c367e1fffa92ae922784631 Deleted: sha256:49c70179bc923a7d48583d58e2b6c21bde1787edf42ed1f8de9e9b96e2e88e65 Deleted: sha256:396e06df5d1120368a7a8a4fd1e5467cdc2dd4083660890df078c654596ddc1c Deleted: sha256:434d118df2e9edb51238f6ba46e9efdfa21be68e88f54787531aa39a720a0740 Deleted: sha256:2047f09c412ff06f4e2ee8a25d105055e714d99000711e27a55072e640796294 Deleted: sha256:13d71c9ccb39b206211dd1900d06aa1984b0f5ab8abaa628c70b3eb733303a65 Deleted: sha256:2edcec3590a4ec7f40cf0743c15d78fb39d8326bc029073b41ef9727da6c851f Untagged: redis:6.0.8 Untagged: redis@sha256:21db12e5ab3cc343e9376d655e8eabbdbe5516801373e95a8a9e66010c5b8819 Deleted: sha256:16ecd277293476392b71021cdd585c40ad68f4a7488752eede95928735e39df4 Deleted: sha256:3746030fff867eb26a0338ad9d3ab832e6c19c7dc008090bcfa95c7b9f16f505 Deleted: sha256:1274ec54ad17d15ec95d2180cb1f791057e86dfcdfcc18cd58610a920e145945 Deleted: sha256:18d156147e54edec9a927080fdc0a53c4a8814b0c717b36dc62e637363c1a98d Deleted: sha256:a8f09c4919857128b1466cc26381de0f9d39a94171534f63859a662d50c396ca Deleted: sha256:2ae5fa95c0fce5ef33fbb87a7e2f49f2a56064566a37a83b97d3f668c10b43d6 Deleted: sha256:d0fe97fa8b8cefdffcef1d62b65aba51a6c87b6679628a2b50fc6a7a579f764c [root@hadoop100 docker]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest feb5d9fea6a5 21 months ago 13.3kB [root@hadoop100 d
[root@hadoop100 docker]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE redis latest 7614ae9453d1 18 months ago 113MB hello-world latest feb5d9fea6a5 21 months ago 13.3kB redis 6.0.8 16ecd2772934 2 years ago 104MB -- 强制删除所有镜像 [root@hadoop100 docker]# docker rmi -f $(docker images -qa) Untagged: redis:latest Untagged: redis@sha256:db485f2e245b5b3329fdc7eff4eb00f913e09d8feb9ca720788059fdc2ed8339 Deleted: sha256:7614ae9453d1d87e740a2056257a6de7135c84037c367e1fffa92ae922784631 Deleted: sha256:49c70179bc923a7d48583d58e2b6c21bde1787edf42ed1f8de9e9b96e2e88e65 Deleted: sha256:396e06df5d1120368a7a8a4fd1e5467cdc2dd4083660890df078c654596ddc1c Deleted: sha256:434d118df2e9edb51238f6ba46e9efdfa21be68e88f54787531aa39a720a0740 Deleted: sha256:2047f09c412ff06f4e2ee8a25d105055e714d99000711e27a55072e640796294 Deleted: sha256:13d71c9ccb39b206211dd1900d06aa1984b0f5ab8abaa628c70b3eb733303a65 Deleted: sha256:2edcec3590a4ec7f40cf0743c15d78fb39d8326bc029073b41ef9727da6c851f Untagged: hello-world:latest Untagged: hello-world@sha256:2498fce14358aa50ead0cc6c19990fc6ff866ce72aeb5546e1d59caac3d0d60f Deleted: sha256:feb5d9fea6a5e9606aa995e879d862b825965ba48de054caab5ef356dc6b3412 Untagged: redis:6.0.8 Untagged: redis@sha256:21db12e5ab3cc343e9376d655e8eabbdbe5516801373e95a8a9e66010c5b8819 Deleted: sha256:16ecd277293476392b71021cdd585c40ad68f4a7488752eede95928735e39df4 Deleted: sha256:3746030fff867eb26a0338ad9d3ab832e6c19c7dc008090bcfa95c7b9f16f505 Deleted: sha256:1274ec54ad17d15ec95d2180cb1f791057e86dfcdfcc18cd58610a920e145945 Deleted: sha256:18d156147e54edec9a927080fdc0a53c4a8814b0c717b36dc62e637363c1a98d Deleted: sha256:a8f09c4919857128b1466cc26381de0f9d39a94171534f63859a662d50c396ca Deleted: sha256:2ae5fa95c0fce5ef33fbb87a7e2f49f2a56064566a37a83b97d3f668c10b43d6 Deleted: sha256:d0fe97fa8b8cefdffcef1d62b65aba51a6c87b6679628a2b50fc6a7a579f764c [root@hadoop100 docker]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE [root@hadoop100 docker]#
docker虚悬镜像
仓库名、标签都是<none>的镜像,俗称虚悬镜像 dangling image