인라인 캐시

인라인 캐시 (Inline cache)

inline 캐시 스토리지 백엔드는 외부 캐시를 얻는 가장 간단한 방법이에요. 이미 이미지를 빌드하고 push하고 있다면 시작하기도 쉬워요.

출처: 문서

본문

inline 캐시의 단점은 멀티스테이지 빌드에서 다른 드라이버만큼 확장이 잘 되지 않는다는 점이에요. 또한 출력 산출물과 캐시 출력을 분리하지 못해요. 따라서 특히 복잡한 빌드 플로우를 쓰거나 이미지를 레지스트리로 직접 내보내지 않는다면, registry 캐시를 고려하는 것이 나을 수 있어요.

시놉시스 (Synopsis)

$ docker buildx build --push -t <registry>/<image> \
  --cache-to type=inline \
  --cache-from type=registry,ref=<registry>/<image> .

--cache-to type=inline으로 캐시를 이미지에 내장할 수 있어요:

$ docker buildx build --push -t <registry>/<image> \
  --cache-to type=inline .

레거시 방식으로 BUILDKIT_INLINE_CACHE 빌드 인자를 쓸 수도 있어요:

$ docker buildx build --push -t <registry>/<image> \
  --build-arg BUILDKIT_INLINE_CACHE=1 .

그리고 지정된 레지스트리의 Docker 이미지 안에서 캐시를 추출하려면:

$ docker buildx build --push -t <registry>/<image> \
  --cache-from type=registry,ref=<registry>/<image> .

추가 자료 (Further reading)

캐싱에 대한 소개는 Docker build cache 문서를, inline 캐시 백엔드에 대한 자세한 내용은 BuildKit README를 참고해요.

더 알아보기 (Learn more)