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

VOLUME is persisting with buildkit, but not with plain docker (18.09.2) #880

Closed
WebHare-bv opened this issue Mar 15, 2019 · 2 comments
Closed

Comments

@WebHare-bv
Copy link

Platform: OSX Mojave

It looks like volumes created with VOLUME persist through build steps (and even in the final image) when using the buildkit. The standard Docker clear the VOLUME, and this is also what I understand should happen from the documentation

Dockerfile:

FROM busybox
RUN mkdir -p /test
VOLUME /test
RUN echo "Hello, world" > /test/file
RUN cat /test/file

the standard docker build doesn't persist /test/ between steps so the 'cat' fails:

$ docker build --no-cache .
.....
Step 5/5 : RUN cat /test/file
 ---> Running in 508faaf32e1f
cat: can't open '/test/file': No such file or directory

but with buildkit the volume is persists and the final RUN can still see the test file:

$ DOCKER_BUILDKIT=1 docker build --no-cache --progress=plain .
....
#6 [4/4] RUN cat /test/file
#6       digest: sha256:33aa1ed7730b10409b17983d71510b991c6927e4b5e3eaebe103e67ca9c04185
#6         name: "[4/4] RUN cat /test/file"
#6      started: 2019-03-15 21:11:41.496686392 +0000 UTC
#6 0.615 Hello, world
@WebHare-bv WebHare-bv changed the title VOLUME is persisting with buildkit, but not with plain docker VOLUME is persisting with buildkit, but not with plain docker (18.09.2) Mar 15, 2019
@tonistiigi
Copy link
Member

It's not that the old builder doesn't persist the directory but a side effect that in old builder all RUN commands need to run with the same config as the image that is being created. So the RUN creates a container and a new volume for it, next RUN creates a new volume and so on. The data still remains in the image.

There is a bugreport for that behavior in moby/moby#3639 . Buildkit fixes it by making the VOLUME metadata only-command like the rest so it only affects the final image. If you for some reason want a writable area in your build that doesn't persist you can use the --mount type=tmpfs,target=/path in buildkit

@WebHare-bv
Copy link
Author

WebHare-bv commented Mar 15, 2019

Thanks! It was an incompatibility I discovered switching the build proces over, but good to know that the buildkit's behavior was actually the intended behavior.

tmpfs was the workaround we already switched to, so good to know we can keep doing that!

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

No branches or pull requests

2 participants