docker cache 삭제하기
🐋

docker cache 삭제하기

Tags
Docker
DEV
Published
July 25, 2023
Author
유레미 EUREMI
docker image를 build했더니 build에 실패했는데 원인은 no space left on device 공간이 없어서이다. docker system df -v로 확인해보니 엄청나게 많은 cache가 쌓여있었다. docker는 layer를 쌓을 때 cache를 이용해 이미지 빌드와 컨테이너 생성 시간을 줄이기 때문이다.
$docker system df -v Images space usage: REPOSITORY TAG IMAGE ID CREATED SIZE SHARED SIZE UNIQUE SIZE CONTAINERS snapshot latest 35grewd50504 12 days ago 14.97GB 0B 14.97GB 0 latest latest efdkd936hd3c 2 weeks ago 29.59GB 0B 29.59GB 0 Containers space usage: CONTAINER ID IMAGE COMMAND LOCAL VOLUMES SIZE CREATED STATUS NAMES Local Volumes space usage: VOLUME NAME LINKS SIZE Build cache usage: 14.63GB
따라서 cache를 제거해 용량을 확보하려 한다.
cache 삭제 명령어는 아래처럼 하면 된다.
sudo docker system prune -a
그러면 아래처럼 password를 입력하라고 한다. 입력하면 cache를 삭제한다.
맨 마지막 라인에 제거된 cache의 전체 용량을 확인할 수 있다.
Password: WARNING! This will remove: - all stopped containers - all networks not used by at least one container - all images without at least one container associated to them - all build cache Are you sure you want to continue? [y/N] y Deleted Images: Deleted build cache objects: Total reclaimed space: 41.62GB
41GB나 됐다…얼마나 정리를 안한건지..🤭