allow image sources without build instructions to be exported to local cache
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 10.3k
- Forks
- 1.5k
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 48
Description
Reproduce steps:
Start a test docker container:
docker run -v /var/lib --privileged --entrypoint=/bin/bash -ti registry.cn-beijing.aliyuncs.com/build-steps/buildkit-docker-build:0.03
Add file /root/Dockerfile:
FROM registry.cn-beijing.aliyuncs.com/hub-mirrors/alpine
COPY datetime /root/datetime
Start buildkitd:
nohup sudo buildkitd >> /root/buildkitd.log 2>&1 &
Run build and export cache:
date > /root/datetime
buildctl build --frontend dockerfile.v0 --local context=/root --local dockerfile=/root --export-cache type=local,dest=/tmp/cache
Prune cache(exported not included)
buildctl prune
Run build with import cache:
date > /root/datetime
buildctl build --frontend dockerfile.v0 --local context=/root --local dockerfile=/root --import-cache type=local,src=/tmp/cache
Expected: FROM layer should be cached
Actual: FROM layer is not cached:
root@cad664359809:/# buildctl build --frontend dockerfile.v0 --local context=/root --local dockerfile=/root --import-cache type=local,src=/tmp/cache
[+] Building 4.0s (7/7) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 124B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for registry.cn-beijing.aliyuncs.com/hub-mirrors/alpine:latest 1.6s
=> importing cache manifest from local:4635895063274809627 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 78B 0.0s
=> [1/2] FROM registry.cn-beijing.aliyuncs.com/hub-mirrors/alpine@sha256:ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45 2.3s
=> => resolve registry.cn-beijing.aliyuncs.com/hub-mirrors/alpine@sha256:ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45 0.0s
=> => sha256:ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45 528B / 528B 0.0s
=> => sha256:c9b1b535fdd91a9855fb7f82348177e5f019329a58c53c47272962dd60f71fc9 2.80MB / 2.80MB 1.7s
=> => sha256:e7d92cdc71feacf90708cb59182d0df1b911f8ae022d29e8e95d75ca6a99776a 1.51kB / 1.51kB 0.0s
=> => unpacking registry.cn-beijing.aliyuncs.com/hub-mirrors/alpine@sha256:ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45 0.2s
=> [2/2] COPY datetime /root/datetime 0.1s
However, if I run the above steps without changing content of /root/datetime everytime, the FROM layer cache will be used.
root@cad664359809:/# buildctl build --frontend dockerfile.v0 --local context=/root --local dockerfile=/root --import-cache type=local,src=/tmp/cache
[+] Building 1.6s (7/7) FINISHED
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 124B 0.0s
=> [internal] load metadata for registry.cn-beijing.aliyuncs.com/hub-mirrors/alpine:latest 1.2s
=> importing cache manifest from local:2352842902088576311 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 78B 0.0s
=> [1/2] FROM registry.cn-beijing.aliyuncs.com/hub-mirrors/alpine@sha256:ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45 0.0s
=> => resolve registry.cn-beijing.aliyuncs.com/hub-mirrors/alpine@sha256:ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45 0.0s
=> CACHED [2/2] COPY datetime /root/datetime 0.3s
=> => pulling sha256:b7ddb7f7f668bcbf7a6ed32117431b26612480d4df9cfe3350f82762ecc7683e 0.0s
=> => pulling sha256:c9b1b535fdd91a9855fb7f82348177e5f019329a58c53c47272962dd60f71fc9 0.1s
=> => unpacking 0.2s
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided docker run, buildkitd, buildctl build, prune, and local cache import commands, changing /root/datetime between builds. Trace local cache export and import handling for the Dockerfile FROM layer. Done means the FROM layer is reused after the source file changes, matching the expected cached behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100