From 259987596d316df1740f12941309ccc49ea4261b Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 16 Feb 2022 22:32:09 +0100 Subject: [PATCH] docs: custom image with cni networking Signed-off-by: CrazyMax --- docs/cni-networking.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 docs/cni-networking.md diff --git a/docs/cni-networking.md b/docs/cni-networking.md new file mode 100644 index 00000000..9a890867 --- /dev/null +++ b/docs/cni-networking.md @@ -0,0 +1,30 @@ +# CNI networking + +It can be useful to use a bridge network for your builder if for example you +encounter a network port contention during multiple builds. If you're using +the BuildKit image, CNI is not [(yet)](https://github.com/moby/buildkit/issues/28) +available in it. + +But you can create your own BuildKit image with CNI support: + +```dockerfile +ARG BUILDKIT_VERSION=v0.9.3 +ARG CNI_VERSION=v1.0.1 + +FROM --platform=$BUILDPLATFORM alpine AS cni-plugins +RUN apk add --no-cache curl +ARG CNI_VERSION +ARG TARGETOS +ARG TARGETARCH +WORKDIR /opt/cni/bin +RUN curl -Ls https://github.com/containernetworking/plugins/releases/download/$CNI_VERSION/cni-plugins-$TARGETOS-$TARGETARCH-$CNI_VERSION.tgz | tar xzv + +FROM moby/buildkit:${BUILDKIT_VERSION} +ARG BUILDKIT_VERSION +RUN apk add --no-cache iptables +COPY --from=cni-plugins /opt/cni/bin /opt/cni/bin +ADD https://raw.githubusercontent.com/moby/buildkit/${BUILDKIT_VERSION}/hack/fixtures/cni.json /etc/buildkit/cni.json +``` + +Here we use the [CNI config for integration tests in BuildKit](../hack/fixtures/cni.json), +but feel free to use your own config.