Skip to contentSkip to conversation

utils/docker-run: add NO_NETWORK variable

PATCH Applied Thomas Petazzoni via buildroot 1 participant 4 messages Sep 28 – Oct 16

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 utils/docker-run: add NO_NETWORK variable

It is sometimes useful to be able to do an offline build, to make sure the build works properly without network access, so this commit adds a NO_NETWORK environment variable to our docker-run script, which for example allows to do:

$ ./utils/docker-run make source
$ NO_NETWORK=1 ./utils/docker-run make
---
 utils/docker-run | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/docker-run +1 -1
index 27c169db72..60a12455d9 100755
@@ -21,7 +21,7 @@ declare -a docker_opts=(
     --user "$(id -u):$(id -g)"
     --workdir "$(pwd)"
     --security-opt label=disable
-    --network host
+    --network "$([[ "${NO_NETWORK:-0}" == 1 ]] && echo none || echo host)"
 )
 
 declare -a mountpoints=(
Signature · 6 lines
2.55.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Am 28.09.26 um 09:46 schrieb Thomas Petazzoni via buildroot:

Quoted 18 lines

It is sometimes useful to be able to do an offline build, to make sure the build works properly without network access, so this commit adds a NO_NETWORK environment variable to our docker-run script, which for example allows to do:

$ ./utils/docker-run make source
$ NO_NETWORK=1 ./utils/docker-run make
---
  utils/docker-run | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
utils/docker-run +0 -0
index 27c169db72..60a12455d9 100755

utils/docker-run declare -a docker_opts=( · line 24

Quoted 5 lines
utils/docker-run +1 -1
@@ -21,7 +21,7 @@ declare -a docker_opts=(
      --user "$(id -u):$(id -g)"
      --workdir "$(pwd)"
      --security-opt label=disable
-    --network host
+    --network "$([[ "${NO_NETWORK:-0}" == 1 ]] && echo none || echo host)"

I thought we're trying to avoid unnecessary Bashisms? At least that was part of the discussion for my still-pending BR2_EXTERNAL patch [1]. Plain POSIX shell for that check would be:

[ "${NO_NETWORK:-0}" -eq 1 ]

"=" instead of "-eq" would work, too, but it feels a bit silly to use numeric values and then do a string comparison. Looks good to me otherwise.

Best regards,
Fiona

[1] https://patchwork.buildroot.org/project/buildroot/patch/[email protected]/

utils/docker-run declare -a docker_opts=( · line 27

Quoted 3 lines
utils/docker-run +0 -0
  )
 
  declare -a mountpoints=(

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw
Quoted 28 lines · Fiona Klute via buildroot

Am 28.09.26 um 09:46 schrieb Thomas Petazzoni via buildroot:

Quoted 23 lines

It is sometimes useful to be able to do an offline build, to make sure the build works properly without network access, so this commit adds a NO_NETWORK environment variable to our docker-run script, which for example allows to do:

$ ./utils/docker-run make source
$ NO_NETWORK=1 ./utils/docker-run make
---
  utils/docker-run | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
utils/docker-run +1 -1
index 27c169db72..60a12455d9 100755
@@ -21,7 +21,7 @@ declare -a docker_opts=(
      --user "$(id -u):$(id -g)"
      --workdir "$(pwd)"
      --security-opt label=disable
-    --network host
+    --network "$([[ "${NO_NETWORK:-0}" == 1 ]] && echo none || echo 
Quoted 1 line

host)"

I thought we're trying to avoid unnecessary Bashisms? At least that was part of the discussion for my still-pending BR2_EXTERNAL patch [1]. Plain POSIX shell for that check would be:

Quoted 1 line

[ "${NO_NETWORK:-0}" -eq 1 ]

I applied this patch to master, including the suggestion to avoid Bashism.

Quoted 11 lines

"=" instead of "-eq" would work, too, but it feels a bit silly to use numeric values and then do a string comparison. Looks good to me otherwise.

Best regards,
Fiona

[1] https://patchwork.buildroot.org/project/buildroot/patch/[email protected]/

Quoted 2 lines

)

    declare -a mountpoints=(

Best regards,

Julien.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw
In reply to Thomas Petazzoni via buildroot

In reply of:

Quoted 9 lines

It is sometimes useful to be able to do an offline build, to make sure the build works properly without network access, so this commit adds a NO_NETWORK environment variable to our docker-run script, which for example allows to do:

$ ./utils/docker-run make source
$ NO_NETWORK=1 ./utils/docker-run make

Applied to 2025.02.x, 2026.08.x. Thanks

Quoted 9 lines
---
 utils/docker-run | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/docker-run +0 -0
index 27c169db72..60a12455d9 100755

utils/docker-run declare -a docker_opts=( · line 27

Quoted 8 lines
utils/docker-run +1 -1
@@ -21,7 +21,7 @@ declare -a docker_opts=(
     --user "$(id -u):$(id -g)"
     --workdir "$(pwd)"
     --security-opt label=disable
-    --network host
+    --network "$([[ "${NO_NETWORK:-0}" == 1 ]] && echo none || echo host)"
 )
 
 declare -a mountpoints=(

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot