Skip to content

driver: buildkitd-netmode flag to set worker network mode #2270

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

Closed
wants to merge 2 commits into from

Conversation

crazy-max
Copy link
Member

fixes #2256
needs #2268

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@crazy-max crazy-max changed the title Bridge network opt driver: buildkitd-netmode flag to set worker network mode Feb 21, 2024
Comment on lines +457 to +458
FROM alpine
RUN apk add --no-cache curl`)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tonistiigi Let me know if this integration test is enough

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curl doesn't show much. We can test that ip a shows different IP for RUN and RUN --net=host.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there is a bug with bridge network mode and host entitlement:

FROM busybox
RUN ip a
RUN --network=host ip a
$ docker buildx create --name bridge --buildkitd-flags "--debug --allow-insecure-entitlement network.host --oci-worker-net bridge" --driver-opt "image=moby/buildkit:master" --bootstrap
$ docker buildx --builder bridge build --no-cache .
...

#3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s
WARNING: No output specified with 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
ERROR: failed to solve: failed to load LLB: network.host is not allowed

@crazy-max
Copy link
Member Author

ci failure for docs-upstream workflow is not related: #2269

Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Platforms []string
BuildkitdFlags string
BuildkitdConfigFile string
BuildkitdNetmode string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this adding new option to create instead of just defining a new driveropt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me a driver-opt is driver specific (container config for docker-container with docker api, pod specific for k8s api) while buildkitd-(flags|config) is common. I think this would be confusing to put it as driver-opt.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is an important enough case to have a special option. Basically, it is only a test option for v0.13. After v0.14, if bridge becomes default we don't expect anyone to ever use this anymore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After v0.14, if bridge becomes default we don't expect anyone to ever use this anymore.

If we have more network mode in the future that could be valuable I think? Like a wg mode (wireguard) one?

If you don't see this as valuable to keep, I was thinking we could use an env var instead? Something like BUILDKIT_NETMODE or EXPERIMENTAL_BUILDKIT_NETMODE? But current vars https://docs.docker.com/build/building/variables/#build-tool-configuration-variables are not drive for create cmd, only build or bake so might not be ideal 😞

So yeah maybe a driver-opt with a specific description about it saying this is temporary could be ok.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should skip it then and just document setting --buildkitd-flags. We can still keep the test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should skip it then and just document setting --buildkitd-flags. We can still keep the test.

Yeah --buildkitd-netmode is more likely a shorthand for --buildkitd-flags="--oci-worker-net=<mode>". I'm fine just documenting --buildkitd-flags to set custom network mode.

})

// TODO: use stable buildkit image when v0.13.0 released
out, err := createCmd(sb, withArgs("--driver", "docker-container", "--buildkitd-netmode=bridge", "--driver-opt", "image=moby/buildkit:master"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future follow-up: ideally these cases should be handled so that we can test any buildkit version and test can mark itself to be skipped if it doesn't work with specific version.

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 this pull request may close these issues.

[v0.13] allow driver-opt to that sets bridge network as default
2 participants