Docker命令-system

命令

docker system

描述

Manage Docker
显示系统信息和管理docker磁盘空间

用法

1
2
docker system df [OPTIONS]
docker system prune [OPTIONS]

选项

1
2
3
4
5
6
7
8
9
docker system df Options:
--format Pretty-print images using a Go template
--verbose , -v Show detailed information on space usage

docker system prune Options:
--all , -a Remove all unused images not just dangling ones
--filter Provide filter values (e.g. 'label=<key>=<value>')
--force , -f Do not prompt for confirmation
--volumes Prune volumes

注意

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
$ docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 4 3 22.8MB 22.65MB (10%)
Containers 3 1 3.162kB 1.093kB (34%)
Local Volumes 0 0 0B 0B
Build Cache 0 0 0B 0B

$ docker system df -v
Images space usage:
REPOSITORY TAG IMAGE ID CREATED SIZE SHARED SIZE UNIQUE SIZE CONTAINERS
demo_nginx v2 8ee210f7ce06 5 days ago 22.65MB 22.65MB 1.095kB 0
demo_nginx v1 5f1ab458849a 5 days ago 22.65MB 22.65MB 0B 1
nginx 1.20.1-alpine 4146b18ae794 6 months ago 22.65MB 22.65MB 0B 1

Containers space usage:
CONTAINER ID IMAGE COMMAND LOCAL VOLUMES SIZE CREATED STATUS NAMES
ce2a0c049f9f demo_nginx:v1 "/docker-entrypoint.…" 0 1.09kB 4 days ago Exited (0) 18 hours ago aaa
a8c31015e674 nginx:1.20.1-alpine "/docker-entrypoint.…" 0 2.07kB 5 days ago Up 18 hours nginx

Local Volumes space usage:
VOLUME NAME LINKS SIZE

# SHARED SIZE is the amount of space that an image shares with another one (i.e. their common data)
# UNIQUE SIZE is the amount of space that is only used by a given image
# SIZE is the virtual size of the image, it is the sum of SHARED SIZE and UNIQUE SIZE

$ docker system prune
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all dangling images
- all dangling build cache

Are you sure you want to continue? [y/N] y
Deleted Containers:
ce2a0c049f9f0b3c57931b439307ebf04e1ac09b96c93bb7a3fd61a84db5b84b

Deleted Networks:
vaultwarden_default

Total reclaimed space: 1.093kB

# 删除所有dangling镜像和未使用的镜像,删除未使用的volumes
$ docker system prune -a --volumes