Skip to content

Instantly share code, notes, and snippets.

@tonistiigi
Forked from brad-jones/Dockerfile
Last active September 10, 2020 04:37
Show Gist options
  • Save tonistiigi/1ba21a5bae3b9fd895b28589e57175e9 to your computer and use it in GitHub Desktop.
Save tonistiigi/1ba21a5bae3b9fd895b28589e57175e9 to your computer and use it in GitHub Desktop.
buildkit cache reproducer - see: https://github.com/moby/buildkit/issues/723
/src # docker build --cache-from=localhost:5000/foo:cache .
[+] Building 3.4s (13/13) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 210B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> resolve image config for docker.io/docker/dockerfile:latest 0.6s
=> docker-image://docker.io/docker/dockerfile@sha256:26cdad2543f02dbbe743b8fc0afe0ad270398e0e89bfb03245ed754736ab59ee 1.5s
=> => resolve docker.io/docker/dockerfile@sha256:26cdad2543f02dbbe743b8fc0afe0ad270398e0e89bfb03245ed754736ab59ee 0.0s
=> => sha256:a78280918fd661f792b311d558a4f4ece71099dd8ee2dda215597606376990eb 7.52MB / 7.52MB 1.1s
=> => sha256:26cdad2543f02dbbe743b8fc0afe0ad270398e0e89bfb03245ed754736ab59ee 2.03kB / 2.03kB 0.0s
=> => sha256:4e7704670349cdae408f0114f7e9b48f350932e241bac8d3126631403156f56f 527B / 527B 0.0s
=> => sha256:985dea5272deef388715dc9fda83d3724f85d8313edf177d17f508b3d682b905 635B / 635B 0.0s
=> => extracting sha256:a78280918fd661f792b311d558a4f4ece71099dd8ee2dda215597606376990eb 0.3s
=> [internal] load metadata for docker.io/library/alpine:latest 0.3s
=> importing cache manifest from localhost:5000/foo:cache 0.0s
=> [devel 1/4] FROM docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 0.0s
=> [internal] helper image for file operations 0.0s
=> CACHED [devel 2/4] RUN apk --no-cache add git 0.0s
=> CACHED [devel 3/4] RUN mkdir /app 0.0s
=> CACHED [devel 4/4] RUN touch /app/foo 0.0s
=> CACHED [runtime 1/1] COPY --from=devel /app/. /app 0.2s
=> => pulling sha256:45bbe2efa944395402515ac4200f05fadadf75ee3974f63f311af421bbbe9f3e 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:d975e4993b84512d38cdfb5d0986470e91de74eb1974f33bf3de8fadae61e161 0.0s
FROM alpine:latest AS devel
RUN apk --no-cache add git
RUN mkdir /app
RUN touch /app/foo
FROM scratch AS runtime
COPY --from=devel /app/. /app
--- Starting docker registry
5d413e6811b516b6116e9e92516e1db11509786416c37a399dda9afe70acd503
--- Starting buildkit daemon 1
Unable to find image 'moby/buildkit:v0.3.1' locally
v0.3.1: Pulling from moby/buildkit
4fe2ade4980c: Already exists
23e16c159a3e: Already exists
32806e478f59: Pull complete
Digest: sha256:e11fe4b0f2dc7cdb7d5aa1d39f8e920bada0b66e2b3c805e51ea48015fd19ea6
Status: Downloaded newer image for moby/buildkit:v0.3.1
2febeba132ca88d0a3ba6609e5dcdbb8bdb392ad483d97bf2a9dbebde91a9a74
--- Starting buildkit daemon 2
9153ac3b2383fdd451cfd0c22047a5292135c2b79b39a2a4b51d0362ed786bee
---Waiting for services...
--- Inspecting cache on daemon 1
Reclaimable: 0B
Total: 0B
--- Building with no-cache on daemon 1
[+] Building 8.1s (11/11) FINISHED
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.2s
=> => transferring dockerfile: 183B 0.0s
=> [internal] load metadata for docker.io/library/alpine:latest 1.5s
=> [devel 1/4] FROM docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 2.8s
=> => resolve docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 0.0s
=> => sha256:4fe2ade4980c2dda4fc95858ebb981489baec8c1e4bd282ab1c3560be8ff9bde 2.21MB / 2.21MB 2.6s
=> => sha256:196d12cf6ab19273823e700516e98eb1910b03b17840f9d5509f03858484d321 1.51kB / 1.51kB 0.0s
=> => sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 2.03kB / 2.03kB 0.0s
=> => sha256:02892826401a9d18f0ea01f8a2f35d328ef039db4e1edcc45c630314a0457d5b 528B / 528B 0.0s
=> => unpacking docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 0.1s
=> [internal] helper image for file operations 1.1s
=> => resolve docker.io/tonistiigi/copy:v0.1.7@sha256:9aab7d9ab369c6daf4831bf0653f7592110ab4b7e8a33fee2b9dca546e9d3089 0.5s
=> => sha256:9aab7d9ab369c6daf4831bf0653f7592110ab4b7e8a33fee2b9dca546e9d3089 2.04kB / 2.04kB 0.0s
=> => sha256:f2f4298def7b9af8b5bef79488d0eb14beade2db743a08504315865b3010dd52 1.36kB / 1.36kB 0.0s
=> => sha256:b16fcda8ffa72fc280319967379a6b061ae8684f335d5df662160754c43ce433 1.38kB / 1.38kB 0.0s
=> => sha256:08bf20359e34f0e859ed9251ede8e5600e3c0319a0d0875008058b958aff30e9 300.75kB / 300.75kB 0.2s
=> => sha256:572dd9fa83b20b238273b0eb0921b18e2d8642be58bb367657f1bd71c2ccf0f3 172.86kB / 172.86kB 0.3s
=> => sha256:05fb0b6da3085c804381e8c0f9cd54e59a65f0a7802ac60ce276ba20629f5ed2 70.73kB / 70.73kB 0.4s
=> => sha256:5c6c674792ce138a9058c97a5ef6df32417a80bf42664774d54ce1ada74502f9 98.70kB / 98.70kB 0.4s
=> => sha256:0b9e0c15d44a08746fabce2a371538e8981e36e897fd028ff5f43a5822d5122b 859.51kB / 859.51kB 0.6s
=> => unpacking docker.io/tonistiigi/copy:v0.1.7@sha256:9aab7d9ab369c6daf4831bf0653f7592110ab4b7e8a33fee2b9dca546e9d3089 0.3s
=> [devel 2/4] RUN apk --no-cache add git 1.1s
=> [devel 3/4] RUN mkdir /app 0.2s
=> [devel 4/4] RUN touch /app/foo 0.2s
=> [runtime 1/1] COPY --from=devel /app/. /app 0.2s
=> exporting to image 0.3s
=> => exporting layers 0.1s
=> => exporting manifest sha256:a2e9f610c419fa8ba65a23a1f794af15e7b8b55694824d511347dcf7e80f64e9 0.0s
=> => exporting config sha256:61fea592579d6b88f083dccbe717ba09e4cecf73f5942828d0f3df0b367c861f 0.0s
=> => pushing layers 0.1s
=> => pushing manifest for localhost:5000/foo:buildkit 0.0s
=> exporting cache 1.4s
=> => preparing build cache for export 1.2s
=> => writing layer sha256:4507e2a00039edafab08a36fb1632b11e507f9802a151b820200205084db7883 0.0s
=> => writing layer sha256:4a7a2f71e05f90062ad5b4d7b478155a02a69cc9888939a024c018be96c8a065 0.0s
=> => writing layer sha256:4fe2ade4980c2dda4fc95858ebb981489baec8c1e4bd282ab1c3560be8ff9bde 0.0s
=> => writing layer sha256:ff271469df7181c3ab2783f080cf3be5a93dca6c0ffe90856aebd60898b18f8c 0.1s
=> => writing config sha256:00c49f16827514fcbe7ec157743ccdba9121afcb5e6ad0f95c5c27f88e7cadf4 0.0s
=> => writing manifest sha256:e2f1318c5a64bb2db07e3b27bc1f8d637161f341450293bcd54e2b13dc6c0b19 0.0s
--- Inspecting cache on daemon 1
ID: fb19cfp16kid4s92f99rf40lw
Parent: sha256:df64d3292fd6194b7865d7326af5255db6d81e9df29f48adde61a918fbd8c332
Created at: 2018-11-21 00:20:55.265536708 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 23.04MB
Description: mount / from exec /bin/sh -c apk --no-cache add git
Usage count: 1
Last used: 2018-11-21 00:20:57.666477941 +0000 UTC
Type: regular
ID: sha256:df64d3292fd6194b7865d7326af5255db6d81e9df29f48adde61a918fbd8c332
Created at: 2018-11-21 00:20:54.135744669 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 6.97MB
Description: pulled from docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528
Usage count: 1
Last used: 2018-11-21 00:20:57.659761879 +0000 UTC
Type: regular
ID: sha256:bddd91381a3070172b6d15192390fdf242b310b101a503dcf227491c1a87ff95
Created at: 2018-11-21 00:20:54.751240805 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 1.75MB
Description: pulled from docker.io/tonistiigi/copy:v0.1.7@sha256:9aab7d9ab369c6daf4831bf0653f7592110ab4b7e8a33fee2b9dca546e9d3089
Usage count: 0
Type: regular
ID: sha256:b6c890b896932a9608c47cbbbe443a7907c41fb7c63ad383a3d4ed3fc3b027a4
Parent: sha256:c12bbbf91154ceb14eb15c83bccf186bffdb4d3a99522766aed2f81c5d5f3703
Created at: 2018-11-21 00:20:54.758520593 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 933.75kB
Description: pulled from docker.io/tonistiigi/copy:v0.1.7@sha256:9aab7d9ab369c6daf4831bf0653f7592110ab4b7e8a33fee2b9dca546e9d3089
Usage count: 1
Last used: 2018-11-21 00:20:57.680460252 +0000 UTC
Type: internal
ID: sha256:a793e631dcc84e6d03a224cfe70a0ef771cbeb9862ac85f393bfe40a5c6db4a6
Parent: sha256:bddd91381a3070172b6d15192390fdf242b310b101a503dcf227491c1a87ff95
Created at: 2018-11-21 00:20:54.753143445 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 483.66kB
Description: pulled from docker.io/tonistiigi/copy:v0.1.7@sha256:9aab7d9ab369c6daf4831bf0653f7592110ab4b7e8a33fee2b9dca546e9d3089
Usage count: 0
Type: regular
ID: sha256:c12bbbf91154ceb14eb15c83bccf186bffdb4d3a99522766aed2f81c5d5f3703
Parent: sha256:37ca27683dd91c4973663c93d462a33b4d2a95ace843847f38f278f578a31be6
Created at: 2018-11-21 00:20:54.756943119 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 305.08kB
Description: pulled from docker.io/tonistiigi/copy:v0.1.7@sha256:9aab7d9ab369c6daf4831bf0653f7592110ab4b7e8a33fee2b9dca546e9d3089
Usage count: 0
Type: regular
ID: sha256:37ca27683dd91c4973663c93d462a33b4d2a95ace843847f38f278f578a31be6
Parent: sha256:a793e631dcc84e6d03a224cfe70a0ef771cbeb9862ac85f393bfe40a5c6db4a6
Created at: 2018-11-21 00:20:54.755804956 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 222.75kB
Description: pulled from docker.io/tonistiigi/copy:v0.1.7@sha256:9aab7d9ab369c6daf4831bf0653f7592110ab4b7e8a33fee2b9dca546e9d3089
Usage count: 0
Type: regular
ID: vj1yu4u1mfoe1rvnk5mrttve5
Parent: a395g6xvkbm58v1yzyu52h26o
Created at: 2018-11-21 00:20:55.679237666 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 8.32kB
Description: mount / from exec /bin/sh -c touch /app/foo
Usage count: 1
Last used: 2018-11-21 00:20:57.669268402 +0000 UTC
Type: regular
ID: tf8r60x5i9ful7kxnjmwogw0b
Created at: 2018-11-21 00:20:55.943275492 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 8.32kB
Description: mount /dest from exec copy /src-0 app
Usage count: 1
Last used: 2018-11-21 00:20:57.671901111 +0000 UTC
Type: regular
ID: a395g6xvkbm58v1yzyu52h26o
Parent: fb19cfp16kid4s92f99rf40lw
Created at: 2018-11-21 00:20:55.45777204 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 8.29kB
Description: mount / from exec /bin/sh -c mkdir /app
Usage count: 1
Last used: 2018-11-21 00:20:57.667914234 +0000 UTC
Type: regular
ID: j6m3qulp4ep4k8u9tdc8pamca
Created at: 2018-11-21 00:20:49.665594417 +0000 UTC
Mutable: true
Reclaimable: true
Shared: false
Size: 4.24kB
Description: local source for dockerfile
Usage count: 1
Last used: 2018-11-21 00:20:57.679284512 +0000 UTC
Type: source.local
ID: f6r2624qobxkg2phsr6aqngve
Created at: 2018-11-21 00:20:49.618622968 +0000 UTC
Mutable: true
Reclaimable: true
Shared: false
Size: 4.10kB
Description: local source for context
Usage count: 1
Last used: 2018-11-21 00:20:57.676873389 +0000 UTC
Type: source.local
Reclaimable: 33.74MB
Total: 33.74MB
--- Building with cache on daemon 1
[+] Building 0.6s (11/11) FINISHED
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 32B 0.0s
=> [internal] load metadata for docker.io/library/alpine:latest 0.4s
=> [devel 1/4] FROM docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 0.0s
=> => resolve docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 0.0s
=> [internal] helper image for file operations 0.0s
=> => resolve docker.io/tonistiigi/copy:v0.1.7@sha256:9aab7d9ab369c6daf4831bf0653f7592110ab4b7e8a33fee2b9dca546e9d3089 0.0s
=> CACHED [devel 2/4] RUN apk --no-cache add git 0.0s
=> CACHED [devel 3/4] RUN mkdir /app 0.0s
=> CACHED [devel 4/4] RUN touch /app/foo 0.0s
=> CACHED [runtime 1/1] COPY --from=devel /app/. /app 0.0s
=> exporting to image 0.1s
=> => exporting layers 0.0s
=> => exporting manifest sha256:a2e9f610c419fa8ba65a23a1f794af15e7b8b55694824d511347dcf7e80f64e9 0.0s
=> => exporting config sha256:61fea592579d6b88f083dccbe717ba09e4cecf73f5942828d0f3df0b367c861f 0.0s
=> => pushing layers 0.0s
=> => pushing manifest for localhost:5000/foo:buildkit 0.0s
=> exporting cache 0.0s
=> => preparing build cache for export 0.0s
=> => writing layer sha256:4507e2a00039edafab08a36fb1632b11e507f9802a151b820200205084db7883 0.0s
=> => writing layer sha256:4a7a2f71e05f90062ad5b4d7b478155a02a69cc9888939a024c018be96c8a065 0.0s
=> => writing layer sha256:4fe2ade4980c2dda4fc95858ebb981489baec8c1e4bd282ab1c3560be8ff9bde 0.0s
=> => writing layer sha256:ff271469df7181c3ab2783f080cf3be5a93dca6c0ffe90856aebd60898b18f8c 0.0s
=> => writing config sha256:00c49f16827514fcbe7ec157743ccdba9121afcb5e6ad0f95c5c27f88e7cadf4 0.0s
=> => writing manifest sha256:e2f1318c5a64bb2db07e3b27bc1f8d637161f341450293bcd54e2b13dc6c0b19 0.0s
--- Inspecting cache on daemon 1
ID: fb19cfp16kid4s92f99rf40lw
Parent: sha256:df64d3292fd6194b7865d7326af5255db6d81e9df29f48adde61a918fbd8c332
Created at: 2018-11-21 00:20:55.265536708 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 23.04MB
Description: mount / from exec /bin/sh -c apk --no-cache add git
Usage count: 7
Last used: 2018-11-21 00:20:59.281421058 +0000 UTC
Type: regular
ID: sha256:df64d3292fd6194b7865d7326af5255db6d81e9df29f48adde61a918fbd8c332
Created at: 2018-11-21 00:20:54.135744669 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 6.97MB
Description: pulled from docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528
Usage count: 10
Last used: 2018-11-21 00:20:59.285165219 +0000 UTC
Type: regular
ID: sha256:bddd91381a3070172b6d15192390fdf242b310b101a503dcf227491c1a87ff95
Created at: 2018-11-21 00:20:54.751240805 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 1.75MB
Description: pulled from docker.io/tonistiigi/copy:v0.1.7@sha256:9aab7d9ab369c6daf4831bf0653f7592110ab4b7e8a33fee2b9dca546e9d3089
Usage count: 0
Type: regular
ID: sha256:b6c890b896932a9608c47cbbbe443a7907c41fb7c63ad383a3d4ed3fc3b027a4
Parent: sha256:c12bbbf91154ceb14eb15c83bccf186bffdb4d3a99522766aed2f81c5d5f3703
Created at: 2018-11-21 00:20:54.758520593 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 933.75kB
Description: pulled from docker.io/tonistiigi/copy:v0.1.7@sha256:9aab7d9ab369c6daf4831bf0653f7592110ab4b7e8a33fee2b9dca546e9d3089
Usage count: 1
Last used: 2018-11-21 00:20:57.680460252 +0000 UTC
Type: internal
ID: sha256:a793e631dcc84e6d03a224cfe70a0ef771cbeb9862ac85f393bfe40a5c6db4a6
Parent: sha256:bddd91381a3070172b6d15192390fdf242b310b101a503dcf227491c1a87ff95
Created at: 2018-11-21 00:20:54.753143445 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 483.66kB
Description: pulled from docker.io/tonistiigi/copy:v0.1.7@sha256:9aab7d9ab369c6daf4831bf0653f7592110ab4b7e8a33fee2b9dca546e9d3089
Usage count: 0
Type: regular
ID: sha256:c12bbbf91154ceb14eb15c83bccf186bffdb4d3a99522766aed2f81c5d5f3703
Parent: sha256:37ca27683dd91c4973663c93d462a33b4d2a95ace843847f38f278f578a31be6
Created at: 2018-11-21 00:20:54.756943119 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 305.08kB
Description: pulled from docker.io/tonistiigi/copy:v0.1.7@sha256:9aab7d9ab369c6daf4831bf0653f7592110ab4b7e8a33fee2b9dca546e9d3089
Usage count: 0
Type: regular
ID: sha256:37ca27683dd91c4973663c93d462a33b4d2a95ace843847f38f278f578a31be6
Parent: sha256:a793e631dcc84e6d03a224cfe70a0ef771cbeb9862ac85f393bfe40a5c6db4a6
Created at: 2018-11-21 00:20:54.755804956 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 222.75kB
Description: pulled from docker.io/tonistiigi/copy:v0.1.7@sha256:9aab7d9ab369c6daf4831bf0653f7592110ab4b7e8a33fee2b9dca546e9d3089
Usage count: 0
Type: regular
ID: vj1yu4u1mfoe1rvnk5mrttve5
Parent: a395g6xvkbm58v1yzyu52h26o
Created at: 2018-11-21 00:20:55.679237666 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 8.32kB
Description: mount / from exec /bin/sh -c touch /app/foo
Usage count: 1
Last used: 2018-11-21 00:20:57.669268402 +0000 UTC
Type: regular
ID: tf8r60x5i9ful7kxnjmwogw0b
Created at: 2018-11-21 00:20:55.943275492 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 8.32kB
Description: mount /dest from exec copy /src-0 app
Usage count: 2
Last used: 2018-11-21 00:20:59.306415629 +0000 UTC
Type: regular
ID: a395g6xvkbm58v1yzyu52h26o
Parent: fb19cfp16kid4s92f99rf40lw
Created at: 2018-11-21 00:20:55.45777204 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 8.29kB
Description: mount / from exec /bin/sh -c mkdir /app
Usage count: 4
Last used: 2018-11-21 00:20:59.274154341 +0000 UTC
Type: regular
ID: j6m3qulp4ep4k8u9tdc8pamca
Created at: 2018-11-21 00:20:49.665594417 +0000 UTC
Mutable: true
Reclaimable: true
Shared: false
Size: 4.24kB
Description: local source for dockerfile
Usage count: 2
Last used: 2018-11-21 00:20:59.305260348 +0000 UTC
Type: source.local
ID: f6r2624qobxkg2phsr6aqngve
Created at: 2018-11-21 00:20:49.618622968 +0000 UTC
Mutable: true
Reclaimable: true
Shared: false
Size: 4.10kB
Description: local source for context
Usage count: 2
Last used: 2018-11-21 00:20:59.301292658 +0000 UTC
Type: source.local
Reclaimable: 33.74MB
Total: 33.74MB
--- Inspecting cache on daemon 2
Reclaimable: 0B
Total: 0B
--- Building with cache on daemon 2
[+] Building 2.4s (12/12) FINISHED
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 183B 0.0s
=> [internal] load metadata for docker.io/library/alpine:latest 1.7s
=> importing cache manifest from localhost:5000/foo:cache 0.0s
=> [devel 1/4] FROM docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 0.0s
=> => resolve docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 0.0s
=> [internal] helper image for file operations 0.4s
=> => resolve docker.io/tonistiigi/copy:v0.1.7@sha256:9aab7d9ab369c6daf4831bf0653f7592110ab4b7e8a33fee2b9dca546e9d3089 0.4s
=> CACHED [devel 2/4] RUN apk --no-cache add git 0.0s
=> CACHED [devel 3/4] RUN mkdir /app 0.0s
=> CACHED [devel 4/4] RUN touch /app/foo 0.0s
=> CACHED [runtime 1/1] COPY --from=devel /app/. /app 0.1s
=> => pulling sha256:4a7a2f71e05f90062ad5b4d7b478155a02a69cc9888939a024c018be96c8a065 0.0s
=> => unpacking 0.0s
=> exporting to image 0.1s
=> => exporting layers 0.0s
=> => exporting manifest sha256:a2e9f610c419fa8ba65a23a1f794af15e7b8b55694824d511347dcf7e80f64e9 0.0s
=> => exporting config sha256:61fea592579d6b88f083dccbe717ba09e4cecf73f5942828d0f3df0b367c861f 0.0s
=> => pushing layers 0.0s
=> => pushing manifest for localhost:5000/foo:buildkit 0.0s
=> exporting cache 0.1s
=> => preparing build cache for export 0.0s
=> => writing layer sha256:4507e2a00039edafab08a36fb1632b11e507f9802a151b820200205084db7883 0.0s
=> => writing layer sha256:4a7a2f71e05f90062ad5b4d7b478155a02a69cc9888939a024c018be96c8a065 0.0s
=> => writing layer sha256:4fe2ade4980c2dda4fc95858ebb981489baec8c1e4bd282ab1c3560be8ff9bde 0.0s
=> => writing layer sha256:ff271469df7181c3ab2783f080cf3be5a93dca6c0ffe90856aebd60898b18f8c 0.0s
=> => writing config sha256:938173cb9e9bbc17ceba60a42d80d18c3f630b1362bef0422f7b0ee78f8cbe84 0.0s
=> => writing manifest sha256:cfdadc8d59752f57f03b4e517fa1f654e95cb0bc634d132a6cbb5ee0b2d8878c 0.0s
--- Inspecting cache on daemon 2
ID: sha256:fcd8814356b8a69b13c3999565d58137d23c886ecf31ecfab036847373e62b9e
Created at: 2018-11-21 00:20:55.943275492 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 8.32kB
Description: imported sha256:4a7a2f71e05f90062ad5b4d7b478155a02a69cc9888939a024c018be96c8a065
Usage count: 1
Last used: 2018-11-21 00:21:03.221103755 +0000 UTC
Type: regular
ID: 5aojzdr4u804pq72yjr5fizp6
Created at: 2018-11-21 00:21:00.8304572 +0000 UTC
Mutable: true
Reclaimable: true
Shared: false
Size: 4.24kB
Description: local source for dockerfile
Usage count: 1
Last used: 2018-11-21 00:21:03.220047981 +0000 UTC
Type: source.local
ID: cyaaua43ujl2pd80xp9rba3gl
Created at: 2018-11-21 00:21:00.866221251 +0000 UTC
Mutable: true
Reclaimable: true
Shared: false
Size: 4.10kB
Description: local source for context
Usage count: 1
Last used: 2018-11-21 00:21:03.223367456 +0000 UTC
Type: source.local
Reclaimable: 16.65kB
Total: 16.65kB
--- Cleaning up
registry
buildkit1
buildkit2
#!/usr/bin/env bash
set -euo pipefail;
function finish {
echo -e "\n--- Cleaning up";
docker rm -f -v registry;
docker rm -f -v buildkit1;
docker rm -f -v buildkit2;
}
trap finish EXIT;
echo -e "\n--- Starting docker registry";
docker run -d \
--name registry \
--net host \
registry:2.6.2;
echo -e "\n--- Starting buildkit daemon 1";
docker run -d \
--name buildkit1 \
--privileged \
--net host \
moby/buildkit:v0.3.1 \
--addr tcp://0.0.0.0:1234;
echo -e "\n--- Starting buildkit daemon 2";
docker run -d \
--name buildkit2 \
--privileged \
--net host \
moby/buildkit:v0.3.1 \
--addr tcp://0.0.0.0:4321;
echo -e "\n---Waiting for services...";
sleep 5;
# As expected this has zero cache
echo -e "\n--- Inspecting cache on daemon 1";
docker run --rm -it \
--net host \
--entrypoint='' \
-e BUILDKIT_HOST=tcp://localhost:1234 \
-v $PWD/Dockerfile:/context/Dockerfile \
moby/buildkit:v0.3.1 \
buildctl du -v;
# As expected this is a completely fresh build and appears to push
# both an image and export it's cache succesfully to the registry.
echo -e "\n--- Building with no-cache on daemon 1";
docker run --rm -it \
--net host \
--entrypoint='' \
-e BUILDKIT_HOST=tcp://localhost:1234 \
-v $PWD/Dockerfile:/context/Dockerfile \
moby/buildkit:v0.3.1 \
buildctl build \
--frontend=dockerfile.v0 \
--local context=/context/ \
--local dockerfile=/context/ \
--frontend-opt target=runtime \
--exporter=image \
--exporter-opt name=localhost:5000/foo:buildkit \
--exporter-opt push=true \
--export-cache localhost:5000/foo:cache \
--export-cache-opt mode=max;
# As expected this now shows daemon 1 has cache
echo -e "\n--- Inspecting cache on daemon 1";
docker run --rm -it \
--net host \
--entrypoint='' \
-e BUILDKIT_HOST=tcp://localhost:1234 \
-v $PWD/Dockerfile:/context/Dockerfile \
moby/buildkit:v0.3.1 \
buildctl du -v;
# Both the copy and alpine images are cached but nothing afterwards is.
# This is unexpected, what am I missing?
echo -e "\n--- Building with cache on daemon 1";
docker run --rm -it \
--net host \
--entrypoint='' \
-e BUILDKIT_HOST=tcp://localhost:1234 \
-v $PWD/Dockerfile:/context/Dockerfile \
moby/buildkit:v0.3.1 \
buildctl build \
--frontend=dockerfile.v0 \
--local context=/context/ \
--local dockerfile=/context/ \
--frontend-opt target=runtime \
--exporter=image \
--exporter-opt name=localhost:5000/foo:buildkit \
--exporter-opt push=true \
--export-cache localhost:5000/foo:cache \
--export-cache-opt mode=max;
# Intrestingly daemon 1 now shows what appears to be all layers duplicated
echo -e "\n--- Inspecting cache on daemon 1";
docker run --rm -it \
--net host \
--entrypoint='' \
-e BUILDKIT_HOST=tcp://localhost:1234 \
-v $PWD/Dockerfile:/context/Dockerfile \
moby/buildkit:v0.3.1 \
buildctl du -v;
# As expected this is empty
echo -e "\n--- Inspecting cache on daemon 2";
docker run --rm -it \
--net host \
--entrypoint='' \
-e BUILDKIT_HOST=tcp://localhost:4321 \
-v $PWD/Dockerfile:/context/Dockerfile \
moby/buildkit:v0.3.1 \
buildctl du -v;
# The cache manifest from the registry appears to be loaded but again nothing
# is cached. I would expect that the copy and alpine images to be pulled but
# everything after this I would expect to be cached. Again what am I missing?
echo -e "\n--- Building with cache on daemon 2";
docker run --rm -it \
--net host \
--entrypoint='' \
-e BUILDKIT_HOST=tcp://localhost:4321 \
-v $PWD/Dockerfile:/context/Dockerfile \
moby/buildkit:v0.3.1 \
buildctl build \
--frontend=dockerfile.v0 \
--local context=/context/ \
--local dockerfile=/context/ \
--frontend-opt target=runtime \
--exporter=image \
--exporter-opt name=localhost:5000/foo:buildkit \
--exporter-opt push=true \
--frontend-opt cache-from=localhost:5000/foo:cache \
--export-cache localhost:5000/foo:cache \
--export-cache-opt mode=max;
# Similar results to running a single build on daemon 1
echo -e "\n--- Inspecting cache on daemon 2";
docker run --rm -it \
--net host \
--entrypoint='' \
-e BUILDKIT_HOST=tcp://localhost:4321 \
-v $PWD/Dockerfile:/context/Dockerfile \
moby/buildkit:v0.3.1 \
buildctl du -v;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment