Docker is deperacating building without BuildKit. This represents a significant problem for a project tree.
Importantly, Docker on macOS does not support building without BuildKit.
Case 1 is docker build
WITHOUT buildkit. Not using BuildKit is currently the
default on Linux. However, it presents a warning:
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
BuildKit is currently disabled; enable it by removing the DOCKER_BUILDKIT=0
environment-variable.
Case 2 is docker compose
WITHOUT BuildKit. Not using BuildKit is currently the
default on Linux. However, it presents a warning:
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
BuildKit is currently disabled; enable it by removing the DOCKER_BUILDKIT=0
environment-variable.
Case 3 is docker build
WITH BuildKit.
I'm not sure how to reproduce this with docker buildx
but this proves that it
should be possible. Somehow, DOCKER_BUILD_KIT=1 docker build
enables the
BuildKit builder to see previous images.
Case 4 uses BuildKit via DOCKER_BUILDKIT=1 docker compose
. Importantly macOS
must use BuildKit.
Case 5 uses BuildKit via docker buildx build
. Importantly macOS must use
docker buildx
.
Case 6 uses BuildKit via docker buildx build
and tries to load the image into
the build container using --cache-from
from this blog.
Unfortunately the flag is not well documented by Docker's own documentation.
Note Docker BuildKit can see previous images if using docker build
instead
of docker buildx build
. I'm not sure how to explicitly enable that behavior
for docker buildx build
or for docker compose
.
Linux | macOS | |
---|---|---|
Case 1 (build w/o BuildKit) |
✔️ | ✔️ |
Case 2 (compose w/o BuildKit) |
✔️ | ✔️ |
Case 3 (build w/ BuildKit) |
✔️ | ✔️ |
Case 4 (buildx ) |
❌ (insanity_b fails) |
❌ (insanity_a fails) |
Case 5 (compose w/ BuildKit) |
❌ | ✔️ |
Case 5 (compose w/ BuildKit) |
❌ | ❓ |