From 7739ecc0e43ba1d8ac81e797a788e9e3f479c284 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Fri, 5 Sep 2025 07:51:09 -0700 Subject: [PATCH] Use network=host on docker buildx build We are already creating a custom buildx builder with options set to use host networking. However, there are reports that this isn't sufficient to get builds working in all situations. It is reported that adding --network=host to the build command itself does fix things. Considering we already intend to use host networking (per the custom buildx builder options) lets go ahead and set --network=host on build commands as well. This upstream issue may be related: https://github.com/docker/buildx/issues/1688 to the problems that have been observed, but it doesn't seem to match completely. Maybe upstream behaviors changed since this was origianlly reported? Change-Id: Ie8856cf49b86e89e2bc903033e7a20874b7c9f83 --- roles/build-container-image/tasks/buildx.yaml | 1 + roles/build-docker-image/tasks/buildx.yaml | 1 + roles/upload-docker-image/tasks/buildx.yaml | 1 + 3 files changed, 3 insertions(+) diff --git a/roles/build-container-image/tasks/buildx.yaml b/roles/build-container-image/tasks/buildx.yaml index 93344c919..edc77d2a5 100644 --- a/roles/build-container-image/tasks/buildx.yaml +++ b/roles/build-container-image/tasks/buildx.yaml @@ -19,6 +19,7 @@ docker_buildx_command: >- docker buildx build {{ zj_image.path | default('.') }} {% if containerfile %}-f {{ containerfile }}{% endif %} + --network=host {% if zj_image.target | default(false) -%} --target {{ zj_image.target }} {% endif -%} diff --git a/roles/build-docker-image/tasks/buildx.yaml b/roles/build-docker-image/tasks/buildx.yaml index 77678f7a5..b8543d156 100644 --- a/roles/build-docker-image/tasks/buildx.yaml +++ b/roles/build-docker-image/tasks/buildx.yaml @@ -8,6 +8,7 @@ set_fact: docker_buildx_command: >- docker buildx build {{ zj_image.path | default('.') }} -f {{ zj_image.dockerfile | default(docker_dockerfile) }} + --network=host {% if zj_image.target | default(false) -%} --target {{ zj_image.target }} {% endif -%} diff --git a/roles/upload-docker-image/tasks/buildx.yaml b/roles/upload-docker-image/tasks/buildx.yaml index ca1e5006e..e765d8314 100644 --- a/roles/upload-docker-image/tasks/buildx.yaml +++ b/roles/upload-docker-image/tasks/buildx.yaml @@ -10,6 +10,7 @@ # should result in a noop build and just a push. command: >- docker buildx build {{ zj_image.path | default('.') }} -f {{ zj_image.dockerfile | default(docker_dockerfile) }} + --network=host {% if zj_image.target | default(false) -%} --target {{ zj_image.target }} {% endif -%}