Skip to content

Instantly share code, notes, and snippets.

@brad-jones
Last active September 10, 2020 04:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brad-jones/536064fcc180b62be6febfd2fa843024 to your computer and use it in GitHub Desktop.
Save brad-jones/536064fcc180b62be6febfd2fa843024 to your computer and use it in GitHub Desktop.
buildkit cache reproducer - see: https://github.com/moby/buildkit/issues/723
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
08acdd8899653490f836f1d14a12c3397591b35670db791a5d512b167e30e504
--- Starting buildkit daemon 1
e2e377b0749c4414176903c0aa1354dc868de4c2091ddbdc73394104320016c6
--- Starting buildkit daemon 2
aa46d43e7de711cc508eaa5e41015a0b227486857b480cf1021796c574bcaa79
---Waiting for services...
--- Inspecting cache on daemon 1
Reclaimable: 0B
Total: 0B
--- Building with no-cache on daemon 1
[+] Building 11.4s (11/11) FINISHED
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 241B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/alpine:latest 4.6s
=> [devel 1/4] FROM docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 2.0s
=> => resolve docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 0.0s
=> => sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 2.03kB / 2.03kB 0.0s
=> => sha256:02892826401a9d18f0ea01f8a2f35d328ef039db4e1edcc45c630314a0457d5b 528B / 528B 0.0s
=> => sha256:4fe2ade4980c2dda4fc95858ebb981489baec8c1e4bd282ab1c3560be8ff9bde 2.21MB / 2.21MB 1.8s
=> => sha256:196d12cf6ab19273823e700516e98eb1910b03b17840f9d5509f03858484d321 1.51kB / 1.51kB 0.0s
=> => unpacking docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 0.2s
=> [internal] helper image for file operations 1.3s
=> => resolve docker.io/tonistiigi/copy:v0.1.9@sha256:e8f159d3f00786604b93c675ee2783f8dc194bb565e61ca5788f6a6e9d304061 1.2s
=> => sha256:e8f159d3f00786604b93c675ee2783f8dc194bb565e61ca5788f6a6e9d304061 2.03kB / 2.03kB 0.0s
=> => sha256:a546a4352bcaa6512f885d24fef3d9819e70551b98535ed1995e4b567ac6d05b 736B / 736B 0.0s
=> => sha256:f7b6696c3fee7264ec4486cebe146a6a98aa8d1e46747843107ff473aada8d56 861.00kB / 861.00kB 0.8s
=> => sha256:494e63343c3f0d392e7af8d718979262baec9496a23e97ad110d62b9c90d6182 766B / 766B 0.0s
=> => sha256:df3b4bed1f63b36992540a09e0d10bd3f9d0b082d50810313841d745d7cce368 898.21kB / 898.21kB 0.9s
=> => unpacking docker.io/tonistiigi/copy:v0.1.9@sha256:e8f159d3f00786604b93c675ee2783f8dc194bb565e61ca5788f6a6e9d304061 0.3s
=> [devel 2/4] RUN apk --no-cache add git 1.9s
=> [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:064f713f7422d82a9a21c3a064a17b02945a81771da67d93f91e94fb962e9901 0.0s
=> => exporting config sha256:97132f3957f8c3013d95c45969a964ad00537fdf75bd8fbbc9f6a8d37189e326 0.0s
=> => pushing layers 0.1s
=> => pushing manifest for localhost:5000/foo:buildkit 0.0s
=> exporting cache 1.7s
=> => preparing build cache for export 1.3s
=> => writing layer sha256:395786beaf035afc7e409f836617a882c3f626921ed0f5c1a994aabec34caef2 0.0s
=> => writing layer sha256:4fe2ade4980c2dda4fc95858ebb981489baec8c1e4bd282ab1c3560be8ff9bde 0.1s
=> => writing layer sha256:7162aa2935fdbf281f681013c509681165ca4bb017eec6cdac532110b521cf89 0.1s
=> => writing layer sha256:8c883c32995aef349e793c0c9b0aacda44ac92557eb8f1ad8a3aa7893ce3bb88 0.0s
=> => writing layer sha256:fd6f27e8ce2d793992ee6ac0f7f048125cff4777aa516e2c32b1149132e78916 0.0s
=> => writing config sha256:6af297fb882e9b76e456d89f025b7208c7a71b422a05312d24522518d34c2797 0.0s
=> => writing manifest sha256:22d059b5329f8371dfa99554264664157339717c4e8923917b9eece89768c987 0.0s
--- Inspecting cache on daemon 1
ID: x0bkrfzng70hmt699vwioydlx
Parent: sha256:df64d3292fd6194b7865d7326af5255db6d81e9df29f48adde61a918fbd8c332
Created at: 2018-11-16 02:47:58.094266785 +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-16 02:48:00.873835126 +0000 UTC
Type: regular
ID: sha256:df64d3292fd6194b7865d7326af5255db6d81e9df29f48adde61a918fbd8c332
Created at: 2018-11-16 02:47:56.233710546 +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-16 02:48:00.86887987 +0000 UTC
Type: regular
ID: sha256:857e4ad1a7b8e821513da63420fc2012ed541fb30804d5158394f8917ad2a039
Created at: 2018-11-16 02:47:58.230187882 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 2.57MB
Description: pulled from docker.io/tonistiigi/copy:v0.1.9@sha256:e8f159d3f00786604b93c675ee2783f8dc194bb565e61ca5788f6a6e9d304061
Usage count: 0
Type: regular
ID: sha256:6659c036b8dc14fe733843047df6216d43dc03ae524171b069ea869c96fc74a2
Parent: sha256:857e4ad1a7b8e821513da63420fc2012ed541fb30804d5158394f8917ad2a039
Created at: 2018-11-16 02:47:58.234894617 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 1.75MB
Description: pulled from docker.io/tonistiigi/copy:v0.1.9@sha256:e8f159d3f00786604b93c675ee2783f8dc194bb565e61ca5788f6a6e9d304061
Usage count: 1
Last used: 2018-11-16 02:48:00.863894781 +0000 UTC
Type: internal
ID: v43teezdhmnnz17frtqbj4u57
Parent: lunqc6qau7km2s599ztck3xuo
Created at: 2018-11-16 02:47:58.554368757 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 8.39kB
Description: mount / from exec /bin/sh -c touch /app/foo
Usage count: 1
Last used: 2018-11-16 02:48:00.834443396 +0000 UTC
Type: regular
ID: lunqc6qau7km2s599ztck3xuo
Parent: x0bkrfzng70hmt699vwioydlx
Created at: 2018-11-16 02:47:58.33296395 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 8.37kB
Description: mount / from exec /bin/sh -c mkdir /app
Usage count: 1
Last used: 2018-11-16 02:48:00.829587414 +0000 UTC
Type: regular
ID: n0o8dqbiwkachz1t6efxy3o24
Created at: 2018-11-16 02:47:58.83786879 +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-16 02:48:00.845758779 +0000 UTC
Type: regular
ID: lud0aywhylccmc9n3td6jqi4f
Created at: 2018-11-16 02:47:49.509810109 +0000 UTC
Mutable: true
Reclaimable: true
Shared: false
Size: 4.24kB
Description: local source for dockerfile
Usage count: 1
Last used: 2018-11-16 02:48:00.825046202 +0000 UTC
Type: source.local
ID: pf6cx86abgtoy7uxh3ja3cf72
Created at: 2018-11-16 02:47:49.481920702 +0000 UTC
Mutable: true
Reclaimable: true
Shared: false
Size: 4.10kB
Description: local source for context
Usage count: 1
Last used: 2018-11-16 02:48:00.859145038 +0000 UTC
Type: source.local
Reclaimable: 34.36MB
Total: 34.36MB
--- Building with cache on daemon 1
[+] Building 4.8s (11/11) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 91B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/alpine:latest 0.9s
=> CACHED [devel 1/4] FROM docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 0.0s
=> => resolve docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 0.0s
=> CACHED [internal] helper image for file operations 0.0s
=> => resolve docker.io/tonistiigi/copy:v0.1.9@sha256:e8f159d3f00786604b93c675ee2783f8dc194bb565e61ca5788f6a6e9d304061 0.0s
=> [devel 2/4] RUN apk --no-cache add git 1.3s
=> [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.2s
=> => exporting layers 0.1s
=> => exporting manifest sha256:7f0a27dc45cdd9269ec1f66bd07501aa1623e27ce16f535d5602e3cab44710e5 0.0s
=> => exporting config sha256:6abf1cb44dd36fef41207f91dc03f627c3ab98fc169be9a7f971619493182a95 0.0s
=> => pushing layers 0.1s
=> => pushing manifest for localhost:5000/foo:buildkit 0.0s
=> exporting cache 1.6s
=> => preparing build cache for export 1.3s
=> => writing layer sha256:3798c5f995c2c40c7a054c1d7893588e4f880191bff932c633c147fae93c6177 0.2s
=> => writing layer sha256:4fe2ade4980c2dda4fc95858ebb981489baec8c1e4bd282ab1c3560be8ff9bde 0.0s
=> => writing layer sha256:8c76dc3e3727b7bce3b16aad7d7addc4a2da2ca2b0d04b5b2c9b35f890f2eedf 0.0s
=> => writing layer sha256:a56722cbc3353185863c7622cba44cab631e30b3ff5442711981998301156985 0.0s
=> => writing layer sha256:eecb74d69c171a89feac6cbab126e81f2493e39a681204d78c426be32214be12 0.0s
=> => writing config sha256:e2e905fc948742d70c37437f95bfd05894fc9b226ea00f71cd8bc67126697434 0.0s
=> => writing manifest sha256:e7b90e001e2697d41125666a753cd376744ac8c50e44251da359d8f6ac7793ec 0.0s
--- Inspecting cache on daemon 1
ID: x0bkrfzng70hmt699vwioydlx
Parent: sha256:df64d3292fd6194b7865d7326af5255db6d81e9df29f48adde61a918fbd8c332
Created at: 2018-11-16 02:47:58.094266785 +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-16 02:48:00.873835126 +0000 UTC
Type: regular
ID: 8mihn1qrp0be3wce2cjhqms7e
Parent: sha256:df64d3292fd6194b7865d7326af5255db6d81e9df29f48adde61a918fbd8c332
Created at: 2018-11-16 02:48:04.375464797 +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-16 02:48:07.033210628 +0000 UTC
Type: regular
ID: sha256:df64d3292fd6194b7865d7326af5255db6d81e9df29f48adde61a918fbd8c332
Created at: 2018-11-16 02:47:56.233710546 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 6.97MB
Description: pulled from docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528
Usage count: 2
Last used: 2018-11-16 02:48:06.989539233 +0000 UTC
Type: regular
ID: sha256:857e4ad1a7b8e821513da63420fc2012ed541fb30804d5158394f8917ad2a039
Created at: 2018-11-16 02:47:58.230187882 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 2.57MB
Description: pulled from docker.io/tonistiigi/copy:v0.1.9@sha256:e8f159d3f00786604b93c675ee2783f8dc194bb565e61ca5788f6a6e9d304061
Usage count: 0
Type: regular
ID: sha256:6659c036b8dc14fe733843047df6216d43dc03ae524171b069ea869c96fc74a2
Parent: sha256:857e4ad1a7b8e821513da63420fc2012ed541fb30804d5158394f8917ad2a039
Created at: 2018-11-16 02:47:58.234894617 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 1.75MB
Description: pulled from docker.io/tonistiigi/copy:v0.1.9@sha256:e8f159d3f00786604b93c675ee2783f8dc194bb565e61ca5788f6a6e9d304061
Usage count: 2
Last used: 2018-11-16 02:48:07.014071641 +0000 UTC
Type: internal
ID: 0t67h92tedeu9h4h3yl5iay19
Parent: niyvmrywd8scs2eno5v060yau
Created at: 2018-11-16 02:48:04.811086967 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 8.39kB
Description: mount / from exec /bin/sh -c touch /app/foo
Usage count: 1
Last used: 2018-11-16 02:48:07.023890753 +0000 UTC
Type: regular
ID: v43teezdhmnnz17frtqbj4u57
Parent: lunqc6qau7km2s599ztck3xuo
Created at: 2018-11-16 02:47:58.554368757 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 8.39kB
Description: mount / from exec /bin/sh -c touch /app/foo
Usage count: 1
Last used: 2018-11-16 02:48:00.834443396 +0000 UTC
Type: regular
ID: niyvmrywd8scs2eno5v060yau
Parent: 8mihn1qrp0be3wce2cjhqms7e
Created at: 2018-11-16 02:48:04.611637829 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 8.37kB
Description: mount / from exec /bin/sh -c mkdir /app
Usage count: 1
Last used: 2018-11-16 02:48:07.019180048 +0000 UTC
Type: regular
ID: lunqc6qau7km2s599ztck3xuo
Parent: x0bkrfzng70hmt699vwioydlx
Created at: 2018-11-16 02:47:58.33296395 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 8.37kB
Description: mount / from exec /bin/sh -c mkdir /app
Usage count: 1
Last used: 2018-11-16 02:48:00.829587414 +0000 UTC
Type: regular
ID: op87ym4ky9iiqurfx10085sil
Created at: 2018-11-16 02:48:05.109389202 +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-16 02:48:06.994206286 +0000 UTC
Type: regular
ID: n0o8dqbiwkachz1t6efxy3o24
Created at: 2018-11-16 02:47:58.83786879 +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-16 02:48:00.845758779 +0000 UTC
Type: regular
ID: lud0aywhylccmc9n3td6jqi4f
Created at: 2018-11-16 02:47:49.509810109 +0000 UTC
Mutable: true
Reclaimable: true
Shared: false
Size: 4.24kB
Description: local source for dockerfile
Usage count: 2
Last used: 2018-11-16 02:48:07.009029782 +0000 UTC
Type: source.local
ID: pf6cx86abgtoy7uxh3ja3cf72
Created at: 2018-11-16 02:47:49.481920702 +0000 UTC
Mutable: true
Reclaimable: true
Shared: false
Size: 4.10kB
Description: local source for context
Usage count: 2
Last used: 2018-11-16 02:48:06.984474879 +0000 UTC
Type: source.local
Reclaimable: 57.43MB
Total: 57.43MB
--- Inspecting cache on daemon 2
Reclaimable: 0B
Total: 0B
--- Building with cache on daemon 2
[+] Building 10.7s (12/12) FINISHED
=> importing cache manifest from localhost:5000/foo:cache 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 241B 0.0s
=> [internal] load metadata for docker.io/library/alpine:latest 4.0s
=> [devel 1/4] FROM docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 1.8s
=> => resolve docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 0.0s
=> => sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 2.03kB / 2.03kB 0.0s
=> => sha256:02892826401a9d18f0ea01f8a2f35d328ef039db4e1edcc45c630314a0457d5b 528B / 528B 0.0s
=> => sha256:4fe2ade4980c2dda4fc95858ebb981489baec8c1e4bd282ab1c3560be8ff9bde 2.21MB / 2.21MB 1.6s
=> => sha256:196d12cf6ab19273823e700516e98eb1910b03b17840f9d5509f03858484d321 1.51kB / 1.51kB 0.0s
=> => unpacking docker.io/library/alpine:latest@sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528 0.2s
=> [internal] helper image for file operations 1.0s
=> => resolve docker.io/tonistiigi/copy:v0.1.9@sha256:e8f159d3f00786604b93c675ee2783f8dc194bb565e61ca5788f6a6e9d304061 1.1s
=> => sha256:e8f159d3f00786604b93c675ee2783f8dc194bb565e61ca5788f6a6e9d304061 2.03kB / 2.03kB 0.0s
=> => sha256:a546a4352bcaa6512f885d24fef3d9819e70551b98535ed1995e4b567ac6d05b 736B / 736B 0.0s
=> => sha256:f7b6696c3fee7264ec4486cebe146a6a98aa8d1e46747843107ff473aada8d56 861.00kB / 861.00kB 0.4s
=> => sha256:494e63343c3f0d392e7af8d718979262baec9496a23e97ad110d62b9c90d6182 766B / 766B 0.0s
=> => sha256:df3b4bed1f63b36992540a09e0d10bd3f9d0b082d50810313841d745d7cce368 898.21kB / 898.21kB 0.6s
=> => unpacking docker.io/tonistiigi/copy:v0.1.9@sha256:e8f159d3f00786604b93c675ee2783f8dc194bb565e61ca5788f6a6e9d304061 0.3s
=> [devel 2/4] RUN apk --no-cache add git 2.0s
=> [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:8384ae6ab2ad2b47dcc8b98da377ac2aa76f4af9eb2e956daafd17a540d00c72 0.0s
=> => exporting config sha256:14029b81ff09173be3de83e78d02f9da9ff52a86665794d370dcbb39f20eb066 0.0s
=> => pushing layers 0.1s
=> => pushing manifest for localhost:5000/foo:buildkit 0.0s
=> exporting cache 1.7s
=> => preparing build cache for export 1.4s
=> => writing layer sha256:257d54f4331fab849f0bd24b6ec9025ba5214514462375682d7495085f242523 0.0s
=> => writing layer sha256:4fe2ade4980c2dda4fc95858ebb981489baec8c1e4bd282ab1c3560be8ff9bde 0.0s
=> => writing layer sha256:5171b062d438fa605edbf8c30e60636452d3d9d7f40a3bcd5911c0d32a8576de 0.2s
=> => writing layer sha256:c03f37651f8a0b0af34577eb4205baa68b4fbf3fc3d99df25c0871fbeb185e51 0.0s
=> => writing layer sha256:f3473f7441b91b5bf8b15f4fba7493286ce4739a88a8c43ba840f3c6294cb880 0.0s
=> => writing config sha256:ce9a7b1cc2b3bcf2d1eecf7a38a467d495f1ad1d097205783897d14789bf2d6e 0.0s
=> => writing manifest sha256:24a47fb27f5e9f3c3da7ea7db2cf3c47c0f79a4af1b49cbb280e19bced61407f 0.0s
--- Inspecting cache on daemon 2
ID: ilkjjs1tvsh2ofnvdw6x7zfkq
Parent: sha256:df64d3292fd6194b7865d7326af5255db6d81e9df29f48adde61a918fbd8c332
Created at: 2018-11-16 02:48:16.675302394 +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-16 02:48:19.431819222 +0000 UTC
Type: regular
ID: sha256:df64d3292fd6194b7865d7326af5255db6d81e9df29f48adde61a918fbd8c332
Created at: 2018-11-16 02:48:14.680775368 +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-16 02:48:19.426562483 +0000 UTC
Type: regular
ID: sha256:857e4ad1a7b8e821513da63420fc2012ed541fb30804d5158394f8917ad2a039
Created at: 2018-11-16 02:48:16.533890788 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 2.57MB
Description: pulled from docker.io/tonistiigi/copy:v0.1.9@sha256:e8f159d3f00786604b93c675ee2783f8dc194bb565e61ca5788f6a6e9d304061
Usage count: 0
Type: regular
ID: sha256:6659c036b8dc14fe733843047df6216d43dc03ae524171b069ea869c96fc74a2
Parent: sha256:857e4ad1a7b8e821513da63420fc2012ed541fb30804d5158394f8917ad2a039
Created at: 2018-11-16 02:48:16.538842445 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 1.75MB
Description: pulled from docker.io/tonistiigi/copy:v0.1.9@sha256:e8f159d3f00786604b93c675ee2783f8dc194bb565e61ca5788f6a6e9d304061
Usage count: 1
Last used: 2018-11-16 02:48:19.437057609 +0000 UTC
Type: internal
ID: mjn6t44rcymikgwrl6qpk5yh5
Parent: rdxninodcisk3bsofgqe7q0ls
Created at: 2018-11-16 02:48:17.128814483 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 8.39kB
Description: mount / from exec /bin/sh -c touch /app/foo
Usage count: 1
Last used: 2018-11-16 02:48:19.451873416 +0000 UTC
Type: regular
ID: rdxninodcisk3bsofgqe7q0ls
Parent: ilkjjs1tvsh2ofnvdw6x7zfkq
Created at: 2018-11-16 02:48:16.91015212 +0000 UTC
Mutable: false
Reclaimable: true
Shared: false
Size: 8.37kB
Description: mount / from exec /bin/sh -c mkdir /app
Usage count: 1
Last used: 2018-11-16 02:48:19.461614399 +0000 UTC
Type: regular
ID: brfof5bw0gwex5rnjxhgljc7c
Created at: 2018-11-16 02:48:17.401129568 +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-16 02:48:19.416716557 +0000 UTC
Type: regular
ID: acwrwwzha4ca3z7vhey7yzdt0
Created at: 2018-11-16 02:48:08.753264065 +0000 UTC
Mutable: true
Reclaimable: true
Shared: false
Size: 4.24kB
Description: local source for dockerfile
Usage count: 1
Last used: 2018-11-16 02:48:19.447032029 +0000 UTC
Type: source.local
ID: 4xvtvsj9medsyx53yplm17lq3
Created at: 2018-11-16 02:48:08.727406964 +0000 UTC
Mutable: true
Reclaimable: true
Shared: false
Size: 4.10kB
Description: local source for context
Usage count: 1
Last used: 2018-11-16 02:48:19.411385756 +0000 UTC
Type: source.local
Reclaimable: 34.36MB
Total: 34.36MB
--- 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.2 \
--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.2 \
--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.2 \
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.2 \
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.2 \
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.2 \
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.2 \
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.2 \
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.2 \
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 \
--import-cache 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.2 \
buildctl du -v;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment