Run task inside a container that is connect to a custom network #177

Closed
opened 2023-05-07 11:59:14 +00:00 by joekrom · 1 comment

I would like to be able to connect the container that will run the task to an existing docker network, but after each run a new network is created.
I am starting the runner with ./act_runner -c config.yaml deamon.
And the config.yml looks like follow :

# Example configuration file, it's safe to copy this as the default config file without any modification.

log:
  # The level of logging, can be trace, debug, info, warn, error, fatal
  level: info

runner:
  # Where to store the registration result.
  file: .runner
  # Execute how many tasks concurrently at the same time.
  capacity: 1
  # Extra environment variables to run jobs.
  envs:
    A_TEST_ENV_NAME_1: a_test_env_value_1
    A_TEST_ENV_NAME_2: a_test_env_value_2
  # Extra environment variables to run jobs from a file.
  # It will be ignored if it's empty or the file doesn't exist.
  env_file: .env
  # The timeout for a job to be finished.
  # Please note that the Gitea instance also has a timeout (3h by default) for the job.
  # So the job could be stopped by the Gitea instance if it's timeout is shorter than this.
  timeout: 3h
  # Whether skip verifying the TLS certificate of the Gitea instance.
  insecure: false
  # The timeout for fetching the job from the Gitea instance.
  fetch_timeout: 5s
  # The interval for fetching the job from the Gitea instance.
  fetch_interval: 2s

cache:
  # Enable cache server to use actions/cache.
  enabled: true
  # The directory to store the cache data.
  # If it's empty, the cache data will be stored in $HOME/.cache/actcache.
  dir: ""
  # The host of the cache server.
  # It's not for the address to listen, but the address to connect from job containers.
  # So 0.0.0.0 is a bad choice, leave it empty to detect automatically.
  host: ""
  # The port of the cache server.
  # 0 means to use a random available port.
  port: 0

container:
  # Which network to use for the job containers. Could be bridge, host, none, or the name of a custom network.
  #network_mode: bridge
  network_mode: my_custom_bridge
  # Whether to use privileged mode or not when launching task containers (privileged mode is required for Docker-in-Docker).
  privileged: false
  # And other options to be used when the container is started (eg, --add-host=my.gitea.url:host-gateway).
  options:
  # The parent directory of a job's working directory.
  # If it's empty, /workspace will be used.
  workdir_parent:

How can that be solved , nad how could we specify options to container in the gitea actions ?

I would like to be able to connect the container that will run the task to an existing docker network, but after each run a new network is created. I am starting the runner with ./act_runner -c config.yaml deamon. And the config.yml looks like follow : ``` # Example configuration file, it's safe to copy this as the default config file without any modification. log: # The level of logging, can be trace, debug, info, warn, error, fatal level: info runner: # Where to store the registration result. file: .runner # Execute how many tasks concurrently at the same time. capacity: 1 # Extra environment variables to run jobs. envs: A_TEST_ENV_NAME_1: a_test_env_value_1 A_TEST_ENV_NAME_2: a_test_env_value_2 # Extra environment variables to run jobs from a file. # It will be ignored if it's empty or the file doesn't exist. env_file: .env # The timeout for a job to be finished. # Please note that the Gitea instance also has a timeout (3h by default) for the job. # So the job could be stopped by the Gitea instance if it's timeout is shorter than this. timeout: 3h # Whether skip verifying the TLS certificate of the Gitea instance. insecure: false # The timeout for fetching the job from the Gitea instance. fetch_timeout: 5s # The interval for fetching the job from the Gitea instance. fetch_interval: 2s cache: # Enable cache server to use actions/cache. enabled: true # The directory to store the cache data. # If it's empty, the cache data will be stored in $HOME/.cache/actcache. dir: "" # The host of the cache server. # It's not for the address to listen, but the address to connect from job containers. # So 0.0.0.0 is a bad choice, leave it empty to detect automatically. host: "" # The port of the cache server. # 0 means to use a random available port. port: 0 container: # Which network to use for the job containers. Could be bridge, host, none, or the name of a custom network. #network_mode: bridge network_mode: my_custom_bridge # Whether to use privileged mode or not when launching task containers (privileged mode is required for Docker-in-Docker). privileged: false # And other options to be used when the container is started (eg, --add-host=my.gitea.url:host-gateway). options: # The parent directory of a job's working directory. # If it's empty, /workspace will be used. workdir_parent: ``` How can that be solved , nad how could we specify options to container in the gitea actions ?
wolfogre added the
kind
bug
label 2023-05-08 10:25:46 +00:00
Member

It does seem like a bug.
If configuring like below:

container:
     network_mode: my-net

then exectue docker container inspect <job-container>
image
We can see that the job container is connected to two networks.The job container should only connect to my-net.


It will be fixed in the #184

It does seem like a bug. If configuring like below: ```yaml container: network_mode: my-net ``` then exectue `docker container inspect <job-container>` ![image](/attachments/225e3021-8bc3-40a5-b302-8ccbd7bd21a8) We can see that the job container is connected to two networks.The job container should only connect to `my-net`. --- It will be fixed in the https://gitea.com/gitea/act_runner/pulls/184
314 KiB
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
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: gitea/act_runner#177
No description provided.