[GH-ISSUE #1696] Add customizable "network" option. #838

Closed
opened 2026-03-01 21:46:49 +03:00 by kerem · 5 comments
Owner

Originally created by @ScionOfDesign on GitHub (Mar 24, 2023).
Original GitHub issue: https://github.com/nektos/act/issues/1696

Act version

v0.2.43

Feature description

My workflow has multiple jobs which run in parallel. In GitHub, each runner/job is on its own network. In act, however, the jobs share the same "host" network as can be seen here: https://github.com/nektos/act/blob/master/pkg/runner/run_context.go#L263

The problem is that there are many networking ports being used on the host machine, leading to intermittent port conflicts causing failures.

Passing in a new network option to a container within the workflow doesn't seem to work.

Originally created by @ScionOfDesign on GitHub (Mar 24, 2023). Original GitHub issue: https://github.com/nektos/act/issues/1696 ### Act version v0.2.43 ### Feature description My workflow has multiple jobs which run in parallel. In GitHub, each runner/job is on its own network. In act, however, the jobs share the same "host" network as can be seen here: https://github.com/nektos/act/blob/master/pkg/runner/run_context.go#L263 The _problem_ is that there are many networking ports being used on the host machine, leading to intermittent port conflicts causing failures. Passing in a new network option to a container within the workflow doesn't seem to work.
kerem 2026-03-01 21:46:49 +03:00
Author
Owner

@ChristopherHX commented on GitHub (Mar 24, 2023):

Would --container-options "--network bridge" work?

<!-- gh-comment-id:1482781849 --> @ChristopherHX commented on GitHub (Mar 24, 2023): Would `--container-options "--network bridge"` work?
Author
Owner

@ScionOfDesign commented on GitHub (Mar 24, 2023):

I tried that and unfortunately it did not. It seems that using the host network is hard coded.

<!-- gh-comment-id:1483245660 --> @ScionOfDesign commented on GitHub (Mar 24, 2023): I tried that and unfortunately it did not. It seems that using the host network is hard coded.
Author
Owner

@ChristopherHX commented on GitHub (Mar 24, 2023):

Docker inspect tells me a different story on my end
my workflow

on: push
jobs:
  _:
    runs-on: ubuntu-latest
    steps:
    - run: sleep 10000

my act command

./act -P ubuntu-latest=ubuntu:latest -W w.yml --container-options "--network bridge" --pull=false

I added a sleep call to be able to find the container via docker ps and do a docker inspect.

"NetworkSettings": {
            "Bridge": "",
            "SandboxID": "6f279f928375cb2ae218b62435bbc77b994019d495a6fa6a207fdbb30928b286",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/6f279f928375",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "39552d1137f4c7debf125b2effbce08f7339d11b86ea1b0036763876e587b9d3",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.2",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:02",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "8e649867da0d1a4d4e1e16de1717e246ffd8aaa635940de50607e50fa3231ece",
                    "EndpointID": "39552d1137f4c7debf125b2effbce08f7339d11b86ea1b0036763876e587b9d3",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:02",
                    "DriverOpts": null
                }
            }
        }
    }

It seems that using the host network is hard coded.

Yes, but the --network flag overrides it, both configs get merged.

However if your workflow looks like this than you need to add it to your yaml file for act to respect it

on: push
jobs:
  _:
    runs-on: ubuntu-latest
    container: ubuntu:latest # --container-options are no longer active
    steps:
    - run: sleep 10000

you need to change it to

on: push
jobs:
  _:
    runs-on: ubuntu-latest
    container:
      image: ubuntu:latest
      options: --network bridge # --container-options are no longer active
    steps:
    - run: sleep 10000

BTW I don't like adding every docker cli option one by one to act, --container-options were added for custom docker options like --network

<!-- gh-comment-id:1483385747 --> @ChristopherHX commented on GitHub (Mar 24, 2023): Docker inspect tells me a different story on my end my workflow ```yaml on: push jobs: _: runs-on: ubuntu-latest steps: - run: sleep 10000 ``` my act command ``` ./act -P ubuntu-latest=ubuntu:latest -W w.yml --container-options "--network bridge" --pull=false ``` I added a sleep call to be able to find the container via docker ps and do a docker inspect. ``` "NetworkSettings": { "Bridge": "", "SandboxID": "6f279f928375cb2ae218b62435bbc77b994019d495a6fa6a207fdbb30928b286", "HairpinMode": false, "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "Ports": {}, "SandboxKey": "/var/run/docker/netns/6f279f928375", "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null, "EndpointID": "39552d1137f4c7debf125b2effbce08f7339d11b86ea1b0036763876e587b9d3", "Gateway": "172.17.0.1", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "MacAddress": "02:42:ac:11:00:02", "Networks": { "bridge": { "IPAMConfig": null, "Links": null, "Aliases": null, "NetworkID": "8e649867da0d1a4d4e1e16de1717e246ffd8aaa635940de50607e50fa3231ece", "EndpointID": "39552d1137f4c7debf125b2effbce08f7339d11b86ea1b0036763876e587b9d3", "Gateway": "172.17.0.1", "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:02", "DriverOpts": null } } } } ``` > It seems that using the host network is hard coded. Yes, but the `--network` flag overrides it, both configs get merged. However if your workflow looks like this than you need to add it to your yaml file for act to respect it ```yaml on: push jobs: _: runs-on: ubuntu-latest container: ubuntu:latest # --container-options are no longer active steps: - run: sleep 10000 ``` you need to change it to ```yaml on: push jobs: _: runs-on: ubuntu-latest container: image: ubuntu:latest options: --network bridge # --container-options are no longer active steps: - run: sleep 10000 ``` _BTW I don't like adding every docker cli option one by one to act, `--container-options` were added for custom docker options like `--network`_
Author
Owner

@ScionOfDesign commented on GitHub (Mar 25, 2023):

Ok thanks, that fixes my problem. I didn't realize that:

container:
      image: catthehacker/ubuntu:act-latest

would also override the --container-options.
In fact, I thought that --container-options only applied to steps that had a container: attribute.

<!-- gh-comment-id:1483734848 --> @ScionOfDesign commented on GitHub (Mar 25, 2023): Ok thanks, that fixes my problem. I didn't realize that: ```yaml container: image: catthehacker/ubuntu:act-latest ``` would also override the `--container-options`. In fact, I thought that `--container-options` **only** applied to steps that had a `container:` attribute.
Author
Owner

@eljohnson92 commented on GitHub (Apr 10, 2023):

I've tried testing this and it seems to work adding the options to the yaml directly with ACT, but --network is not supported by GHA runners. it would be nice if --container-options could work even if a container image was provided

<!-- gh-comment-id:1502483791 --> @eljohnson92 commented on GitHub (Apr 10, 2023): I've tried testing this and it seems to work adding the options to the yaml directly with ACT, but `--network` is not supported by GHA runners. it would be nice if --container-options could work even if a container image was provided
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#838
No description provided.