moby / buildkit

concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit
https://github.com/moby/moby/issues/34227
Apache License 2.0
8.03k stars 1.12k forks source link

How do I build a container image with flag `network=host` ? #4533

Open diana-zvulun opened 8 months ago

diana-zvulun commented 8 months ago

I couldn't find anything in the documentation. This is the buildctl command I've used so far but it doesn't look like it worked: buildctl --addr tcp://xxx.xxx.xxx.xxxx:xxxx build --frontend dockerfile.v0 --local context=. --local dockerfile=/docker/ --opt network=host --output type=image,'\"name=repo/repo-name:latest\"',push=true"

Also when adding these options: --opt force-network-mode=host --allow=network.host --allow=security.insecure

I get this error: failed to solve: granting entitlement network.host is not allowed by build daemon configuration

tonistiigi commented 8 months ago

You need to enable this capability in buildkitd config to allow build request to use it because host network is considered insecure.

Insecure entitlements from https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md

diana-zvulun commented 7 months ago

Is there a way to configure it as args to the container? Right now these are my arguments: args: "--addr unix:///run/buildkit/buildkitd.sock --addr tcp://xxx.xxx.xxx.xxx:1234"