From de0644499a555d240bd065f7c6d839e5162df46f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Brauer?= Date: Tue, 18 Apr 2023 16:37:59 +0200 Subject: [PATCH] fix: ensure networkmode "host" unless explicitly specified (#1739) act defaults network mode to "host", but when `--container-options` are passed on the CLI, it uses the docker CLI options parser, which fills empty values with defaults, in which case network mode is set to "default". Unless the user explicitly sets `--container-options="--network=xxx"`, we should always default to "host", to keep act's behaviour. Co-authored-by: Markus Wolf Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- pkg/container/docker_run.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/container/docker_run.go b/pkg/container/docker_run.go index 62390f6..1b194ea 100644 --- a/pkg/container/docker_run.go +++ b/pkg/container/docker_run.go @@ -348,6 +348,12 @@ func (cr *containerReference) mergeContainerConfigs(ctx context.Context, config return nil, nil, fmt.Errorf("Cannot parse container options: '%s': '%w'", input.Options, err) } + if len(copts.netMode.Value()) == 0 { + if err = copts.netMode.Set("host"); err != nil { + return nil, nil, fmt.Errorf("Cannot parse networkmode=host. This is an internal error and should not happen: '%w'", err) + } + } + containerConfig, err := parse(flags, copts, "") if err != nil { return nil, nil, fmt.Errorf("Cannot process container options: '%s': '%w'", input.Options, err)