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

BUG: tagging is broken for multistage builds #1456

Closed
h-vetinari opened this issue Mar 28, 2019 · 16 comments
Closed

BUG: tagging is broken for multistage builds #1456

h-vetinari opened this issue Mar 28, 2019 · 16 comments

Comments

@h-vetinari
Copy link

[Now that I have access to the nightly ppa's (cf. containers/podman#2250), I'm starting to file some issues against podman - and since the issue template there says that podman build issues should be filed for buildah, I'm starting here.]

Assume I have a toy dockerfile, say podman_test.dockrf:

FROM docker.io/library/ubuntu:bionic

RUN apt-get update && apt-get install curl -y

CMD ["bash"]

Then sudo podman build -t podman_test -f podman_test.dockrf . produces
buildah1

So far so good. If I change the dockerfile slightly:

-FROM docker.io/library/ubuntu:bionic
+FROM docker.io/library/ubuntu:bionic as base

 RUN apt-get update && apt-get install curl -y

 CMD ["bash"]

then I get an untagged image (even though it successfully uses the cache):
buildah2

Same for sudo podman build -t podman_test --target=base -f podman_test.dockrf .

This is quite basic functionality IMO - without tagging, many automation tasks are not possible.

@TomSweeneyRedHat
Copy link
Member

TomSweeneyRedHat commented Mar 28, 2019

@h-vetinari thanks for the issue. This is definitely not acting correctly as you surmised. I think the <none><none> is ok for image 21fe, but what I think should be happening is we should have another image there named podman_test with an id of d6ca... , the last line from the build output there.

There appears to be something going on with the --layers option that's not letting that complete successfuly, if I add --layers=false to the podman build command, then I see that image.

I'll have to dig more in the next day or too, and may need to check in with @nalind

@h-vetinari
Copy link
Author

Thanks for the response!

@TomSweeneyRedHat: I think the <none> <none> is ok for image 21fe, but what I think should be happening is we should have another image there named podman_test with an id of d6ca... , the last line from the build output there.

Ideally (IMO) both dockerfiles should create exactly the same image, so that 21fe... is not untagged by the build, but stays the same. Builds not being idempotent is another issue I'm encountering (pending further tests).

@nalind
Copy link
Member

nalind commented Apr 3, 2019

I think #1473 will fix this.

@h-vetinari
Copy link
Author

@nalind @TomSweeneyRedHat
I just tested the newest nightly after I saw that #1473 had been merged - unfortunately, the issue persists (assuming http://ppa.launchpad.net/projectatomic/ppa/ubuntu is up-to-date).

@TomSweeneyRedHat
Copy link
Member

@h-vetinari I'm not sure that's up to date. @lsm5 can you confirm or deny please?

@lsm5
Copy link
Member

lsm5 commented Apr 8, 2019

@h-vetinari what version of ubuntu are you on? I see that 16.04 hasn't been updated in a long time. I'll fix that now. 18.04 was last built on 5th april. Travis auto-builds break often for buildah quite likely due to .travis.yml changes.

@h-vetinari
Copy link
Author

@lsm5
I'm on Ubuntu 18.04. Is the ppa-update not scheduled regularly (e.g. daily)? Can you say if 29a6c81 was already part of the last build?

@nalind @TomSweeneyRedHat
Seems that the last build I tested above (and which fails the scenario laid out in the OP) includes at least #1473, but possibly not #1487.

@h-vetinari
Copy link
Author

@nalind @TomSweeneyRedHat @rhatdan

Just reran the test again, and it still fails, for both of:

sudo podman build -t podman_test -f podman_test.dockrf .
sudo podman build -t podman_test --target=base -f podman_test.dockrf .

Note that this time, apt-get install podman buildah picked up that the ppa had a newer version than yesterday, so it definitely includes #1473 and #1487.

Not sure if #1497 will have any bearing on this, but in any case, it would be very helpful to have this fixed.

@lsm5
Copy link
Member

lsm5 commented Apr 9, 2019 via email

@nalind
Copy link
Member

nalind commented Apr 17, 2019

[Now that I have access to the nightly ppa's (cf. containers/libpod#2250), I'm starting to file some issues against podman - and since the issue template there says that podman build issues should be filed for buildah, I'm starting here.]

Assume I have a toy dockerfile, say podman_test.dockrf:

FROM docker.io/library/ubuntu:bionic

RUN apt-get update && apt-get install curl -y

CMD ["bash"]

Then sudo podman build -t podman_test -f podman_test.dockrf . produces
buildah1

So far so good. If I change the dockerfile slightly:

-FROM docker.io/library/ubuntu:bionic
+FROM docker.io/library/ubuntu:bionic as base

 RUN apt-get update && apt-get install curl -y

 CMD ["bash"]

then I get an untagged image (even though it successfully uses the cache):
buildah2

Same for sudo podman build -t podman_test --target=base -f podman_test.dockrf .

This is quite basic functionality IMO - without tagging, many automation tasks are not possible.

I think what you're after would conventionally be accomplished by building only through that stage with the --target flag, and by using the -t flag to specify a tag to apply to the final image.

The name specified in a FROM ... AS ... instruction is not treated as a tag for the image built at that stage, as its main use is to avoid requiring that subsequent COPY --from= instructions specify stages by number, which can get hard to maintain if you find you need to add a stage to the middle of a multi-stage Dockerfile.

@h-vetinari
Copy link
Author

@h-vetinari: [...]
Same for sudo podman build -t podman_test --target=base -f podman_test.dockrf .
[...]

@nalind: I think what you're after would conventionally be accomplished by building only through that stage with the --target flag, and by using the -t flag to specify a tag to apply to the final image.

This is exactly what is not working, and what this issue is about, see self-quote from OP. Neither does it work to build the full image (no --target) - the final image currently ignores the -t tag.

@nalind
Copy link
Member

nalind commented Apr 17, 2019

Aargh, I missed that. This appears to work correctly with buildah at least as of version ffd8d6a, though, so I expect we're looking at containers/podman#2931 to incorporate those changes into podman.

@h-vetinari
Copy link
Author

@nalind
I've been trying to monitor the PRs and regularly tested with the most current nightly builds for podman/buildah. Seems that this specific commit hasn't made it to the PPA yet, so I can't verify. But thanks for fixing! :)

Yeah, would definitely need to update the version vendored by podman, as I'm planning to use this through podman.

@h-vetinari
Copy link
Author

@nalind
Never mind, I hadn't completely thought through the effects of the vendoring...

Using the latest PPA, it works correctly to do either of:

  • sudo buildah bud -t podman_test -f podman_test.dockrf .
  • sudo buildah bud -t podman_test --target=base -f podman_test.dockrf .

@h-vetinari
Copy link
Author

Thanks!

@h-vetinari
Copy link
Author

Just checked with the new PPA after containers/podman#2931, and now it works with podman build too! :)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants