Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline cache not working with dockerd 27.1.1 #5242

Closed
tom93 opened this issue Aug 12, 2024 · 0 comments · Fixed by #5257
Closed

Inline cache not working with dockerd 27.1.1 #5242

tom93 opened this issue Aug 12, 2024 · 0 comments · Fixed by #5257

Comments

@tom93
Copy link

tom93 commented Aug 12, 2024

I'm using docker:27.1.1-dind (latest at the time of writing), and inline cache with --cache-from doesn't work (RUN steps are re-executed instead of being cached). I've bisected this to 26.1.4-dind (good) / 27.0.0-rc.1-dind (bad).

Somewhat similar: #2274.

Steps (using save/load from tar):

# create a docker-in-docker environment (all the following commands run inside this environment)
docker run --rm -it --privileged docker:27.1.1-dind sh -c 'unset DOCKER_HOST; dockerd &>/tmp/log & exec sh'

# create Dockerfile
mkdir app
cat > app/Dockerfile <<"EOF"
FROM busybox@sha256:9ae97d36d26566ff84e8893c64a6dc4fe8ca6d1144bf5b87b2b85a32def253c7
RUN echo this command was not cached | tr a-z A-Z; sleep 3
EOF

# build & save
docker build --cache-to type=inline -t local.example/img app
docker save local.example/img > img.tar

# wipe the local build cache
docker rmi local.example/img
docker system prune -f

# try to build using the loaded image
docker load < img.tar
docker build --cache-from local.example/img -t local.example/img app

The cache isn't used during the second build command. I can tell this because:

  • when the second build is running, the message "THIS COMMAND WAS NOT CACHED" is visible for a few seconds (afterwards it's hidden due to the tty progress format)
  • when the second build finishes, the line " => [2/2] RUN echo ..." (without the word "CACHED") shows that the RUN step wasn't cached

There are no error messages.

Steps (using a local registry):

# run a local registry
docker run --name registry.example -e REGISTRY_HTTP_ADDR=0.0.0.0:80 registry

# create a docker-in-docker environment
docker run --rm -it --link registry.example --privileged docker:27.1.1-dind sh -c 'unset DOCKER_HOST; dockerd --insecure-registry=registry.example &>/tmp/log & exec sh'

# create Dockerfile
mkdir app
cat > app/Dockerfile <<"EOF"
FROM busybox@sha256:9ae97d36d26566ff84e8893c64a6dc4fe8ca6d1144bf5b87b2b85a32def253c7
RUN echo this command was not cached | tr a-z A-Z; sleep 3
EOF

# build & push
docker build --cache-to type=inline -t registry.example/img app
docker push registry.example/img

# wipe the local build cache (emulates a clean machine)
docker rmi registry.example/img
docker system prune -f

# try to build using the registry cache
docker pull registry.example/img
docker build --cache-from registry.example/img -t registry.example/img app
tonistiigi added a commit to tonistiigi/docker that referenced this issue Aug 15, 2024
Also brings in fix for moby/buildkit#5242

Signed-off-by: Tonis Tiigi <[email protected]>
tonistiigi added a commit to tonistiigi/docker that referenced this issue Aug 15, 2024
Also brings in fix for moby/buildkit#5242

Signed-off-by: Tonis Tiigi <[email protected]>
(cherry picked from commit c459986)
maggie44 pushed a commit to maggie44/moby that referenced this issue Dec 8, 2024
Also brings in fix for moby/buildkit#5242

Signed-off-by: Tonis Tiigi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant