docker buildx prune

docker buildx prune

docker buildx prune은 빌드 캐시를 정리하는 명령이에요. 삭제 가능한 캐시를 지워 디스크 공간을 확보할 때 사용해요.

출처: 문서

본문

docker buildx prune은 현재 빌더의 빌드 캐시를 정리해요. --all로 내부·프론트엔드 이미지를 포함하고, --filter로 조건을, --max-used-space·--min-free-space·--reserved-space로 공간 정책을 지정할 수 있어요.

지원하는 옵션은 다음과 같아요.

옵션 기본값 설명
-a, --all 모든 항목을 보여줘요 (기본은 실행 중만)
--filter 조건에 따라 출력을 필터링해요
-f, --force 확인 프롬프트 없이 강제로 실행해요
--max-used-space 캐시에 두는 최대 디스크 공간
--min-free-space 정리 후 확보할 디스크 공간 목표
--reserved-space 캐시에 항상 두는 디스크 공간
--timeout 20s 연결 시 또는 이미 실행 중일 때 컨테이너 종료에 쓰는 타임아웃(초)을 정해요
--verbose --format=pretty의 축약형이에요

Include internal/frontend images (--all)

--all로 내부·프론트엔드 이미지를 삭제 대상에 포함해요.

$ docker buildx prune --all

Provide filter values (--filter)

--filter로 삭제 대상 조건을 지정해요.

$ docker buildx prune --filter until=24h

Maximum amount of disk space allowed to keep for cache (--max-used-space)

--max-used-space로 캐시에 둘 수 있는 최대 디스크 공간을 지정해요.

$ docker buildx prune --max-used-space 20GB

Target amount of free disk space after pruning (--min-free-space)

--min-free-space로 정리 후 확보할 디스크 공간 목표를 지정해요.

$ docker buildx prune --min-free-space 20GB

Amount of disk space always allowed to keep for cache (--reserved-space)

--reserved-space로 캐시를 위해 항상 유지할 디스크 공간을 지정해요.

$ docker buildx prune --reserved-space 20GB

Override the configured builder instance (--builder)

buildx --builder와 동일해요.

더 알아보기