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

dockerfile2llb: ADD wildcard tar doesn't extract tarball to destination #786

Closed
cirocosta opened this issue Jan 16, 2019 · 0 comments · Fixed by #809
Closed

dockerfile2llb: ADD wildcard tar doesn't extract tarball to destination #786

cirocosta opened this issue Jan 16, 2019 · 0 comments · Fixed by #809

Comments

@cirocosta
Copy link
Contributor

cirocosta commented Jan 16, 2019

Hey,

First of all, thanks a lot for all of your efforts on buildkit!

Onto the issue,

It appears that builds using buildkit differ a bit from those using the plain old docker when it comes to the ADD directive when combined with wildcards.

For instance, while ADD ./*.tgz /dest in the old docker builder we end up with the extracted contents under /dest, with buildkit, that's not the observed.

Here's a reproducible:

tar --list --file=./mything.tgz
./a
./b
./c
# vim: set ft=Dockerfile:
# Dockerfile.with-wildcard
FROM busybox

ADD ./*.tgz /dest
# vim: set ft=Dockerfile:
# Dockerfile.without-wildcard
FROM busybox

ADD ./mything.tgz /dest

By building them with DOCKER_BUILDKIT enabled and disabled, we can observe how different the results are.

Here's a Makefile that can make that process simpler:

run: | build-with-wildcard build-without-wildcard run-with-wildcard run-without-wildcard

run-%:
	docker run \
	  --rm \
	  $* \
	  /bin/sh -c 'ls /dest'

build-%:
	  docker build \
	    --no-cache \
	    -f ./Dockerfile.$* \
	    -t $* \
	    .

Executing make run and DOCKER_BUILDKIT=1 make run:

DOCKER_BUILDKIT=1 make run
# ...
docker run \
	  --rm \
	  with-wildcard \
	  /bin/sh -c 'ls /dest'
/dest
docker run \
	  --rm \
	  without-wildcard \
	  /bin/sh -c 'ls /dest'
a
b
c
make run
docker run \
	  --rm \
	  with-wildcard \
	  /bin/sh -c 'ls /dest'
a
b
c
docker run \
	  --rm \
	  without-wildcard \
	  /bin/sh -c 'ls /dest'
a
b
c

Something I noticed is that there are no tests for this case: https://github.com/tonistiigi/buildkit/blob/6cb4256e81dd20691d9c71a988d0791aee02e00b/frontend/dockerfile/dockerfile_test.go#L38-L49

Please let me know if you'd like any extra info.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants