docker build 报没有磁盘空间错误。
ERROR: failed to solve: failed to copy files: userspace copy failed: write /var/lib/docker/overlay2/s2td1axw9vdy5c88lj64lm5wi/merged/xxx-install/packages/alsa-firmware-1.0.28-2.el7.noarch.rpm: no space left on device
宿主机上 df -h
看了下,是有空间的。看来是 docker 内部的问题。执行 docker system df
看下:
$ docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 9 4 6.307GB 2.057GB (32%)
Containers 4 4 33.88MB 0B (0%)
Local Volumes 6 2 994.8MB 701.8MB (70%)
Build Cache 38 0 5.706GB 5.706GB
发现 build cache 非常大。docker system
执行试了试:
$ docker system
Usage: docker system COMMAND
Manage Docker
Commands:
df Show docker disk usage
events Get real time events from the server
info Display system-wide information
prune Remove unused data
Run 'docker system COMMAND --help' for more information on a command.
发现有个 prune 命令,描述是 Remove unused data
。执行下 docker system prune
(清空前会有个确认,输入 y 确认):
$ 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 build cache objects:
hzt7mkqkaz6cwjk6gxtpkuo4u
lqeopir688oabdt2xak6prxh6
Total reclaimed space: 5.706GB
再次执行 docker build
,好了。