-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
build: set default context builder if not specified #3676
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #3676 +/- ##
==========================================
+ Coverage 58.81% 58.84% +0.03%
==========================================
Files 286 286
Lines 24640 24664 +24
==========================================
+ Hits 14491 14514 +23
- Misses 9265 9266 +1
Partials 884 884 |
e0293f1
to
e4fe231
Compare
I'm not sure, does this work across multiple contexts? e.g. on dd4l, the So always forcing to the |
Good point, we might trigger this error if using |
e4fe231
to
59db7c9
Compare
So this means The other option I was thinking of involved changing the default flags when running Once this and |
Yes that's it
This can be tricky as user might want to push its image which would not work as multi-exporters are not currently supported with BuildKit: moby/buildkit#1555 |
Seems like the right behavior now! 🎉 |
Hmmm.. bit on the fence; so IIRC, the intent was to make However, if a container-builder is the active builder, and no useful output was given (neither Wondering if we can do something with that information (no output given), and use |
As discussed on Slack, I think it still makes sense to use the default context for
Don't think this is an issue as users can still use
Let me know if you have the same or other concerns and how we can improve that. |
My bigger concern is when running something like a Makefile from a cloned git repo, the |
This still feels as a very specific use-case, and it's odd that this was chosen to be the default, and not an opt-in (more below).
So, it depends how you ran it in 20.10. If I didn't opt-in to use With the built-in BuildKit client (on 20.10); DOCKER_BUILDKIT=1 docker build -t foo -<<'EOF'
FROM busybox
RUN echo hello
EOF
[+] Building 4.7s (6/6) FINISHED
=> [internal] load build definition from Dockerfile 0.3s
=> => transferring dockerfile: 70B 0.1s
=> [internal] load .dockerignore 0.2s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/busybox:latest 0.0s
=> CACHED [1/2] FROM docker.io/library/busybox 0.0s
=> [2/2] RUN echo hello 3.9s
=> exporting to image 0.3s
=> => exporting layers 0.2s
=> => writing image sha256:66ed75cd29b095e1bdcee7720f7960cdcdedae33f6b322c3d2e57e3f24e17ee2 0.0s
=> => naming to docker.io/library/foo However, if I opted-in to using buildx ( docker buildx install
docker build -t foo -<<'EOF'
FROM busybox
RUN echo hello
EOF
[+] Building 6.2s (5/5) FINISHED
=> [internal] load build definition from Dockerfile 0.8s
=> => transferring dockerfile: 65B 0.1s
=> [internal] load .dockerignore 0.6s
=> => transferring context: 2B 0.1s
=> [internal] load metadata for docker.io/library/busybox:latest 3.7s
=> [1/2] FROM docker.io/library/busybox@sha256:3614ca5eacf0a3a1bcc361c939202a974b4902b9334ff36eb29ffe9011aaad83 0.9s
=> => resolve docker.io/library/busybox@sha256:3614ca5eacf0a3a1bcc361c939202a974b4902b9334ff36eb29ffe9011aaad83 0.0s
=> => sha256:19d511225f94f9b5cbf3836eb02b5273c01b95da50735742560e3e45b8c8bfcc 773.26kB / 773.26kB 0.4s
=> => extracting sha256:19d511225f94f9b5cbf3836eb02b5273c01b95da50735742560e3e45b8c8bfcc 0.3s
=> [2/2] RUN echo hello 0.4s
WARNING: No output specified for docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load Overall, I prefer the latter over the earlier one (I even would've preferred it to be an error at the start - when dealing with ambiguous situations, it's better to produce an error to prevent people from using it, than not; an error can later turned into a feature, a "non-error" will result in a backward-incompatible change).
Some options;
Of the above;
|
@thaJeztah If you insist, we could keep the old behavior of After buildx is default I think most of the appeal of |
Ah, sorry, I meant to reply; I wasn't 100% sure what the proposal was 😅 On 22.06 (buildx as default), I would consider that the equivalent as docker builder create --use --name foo --driver=docker-container
echo "FROM alpine" | docker build -
...
WARNING: No output specified for docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load If the proposal is to make that the behaviour, that sounds good to me (making it a hard error if no explicit output is set would still be my preference, but I realise that requires more changes). Can we print the warning (both?) at the start (and at the end)? |
59db7c9
to
164adce
Compare
088e27e
to
905a54a
Compare
As discussed, do not enforce the default context if a builder alias is set ("buildx install") so user keeps the same build experience. |
7d44338
to
b9a1276
Compare
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
b9a1276
to
9978469
Compare
- What I did
if build subcommand has changed to a builder alias (buildx),
user would expect
docker build
to always create a local dockerimage (default context builder). this is for better backward
compatibility in case where a user could switch to a docker container
builder with
docker buildx --use foo
which does not--load
by default.also makes sure that an arbitrary builder name is not being set in the
command line or in the environment before setting the default context.
- How I did it
- How to verify it
Default builder:
Create and use docker-container builder:
- Description for the changelog
cc @tonistiigi @jedevc
- A picture of a cute animal (not mandatory but encouraged)
Signed-off-by: CrazyMax crazy-max@users.noreply.github.com