Services not added as hostnames #173

Open
opened 2024-04-03 20:52:53 +00:00 by rafadc · 5 comments

Test case

Let's use this action

on: [push]

jobs:
  tests:
    runs-on: ubuntu-latest
    container: node:12.16.1-stretch
    services:
     postgres:
       image: postgres:16.2
       env:
         POSTGRES_USER: postgres
         POSTGRES_PASSWORD: ""
         POSTGRES_DB: postgres
       ports:
       - 5432:5432
       # needed because the postgres container does not provide a healthcheck
       options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5

    steps:
      - run: ping -c 4 postgres

Observed behaviour

If I run this with forgejo-runner exec --workflows myaction.yaml

I get

...
[myaction.yaml/tests] ⭐ Run Main ping -c 4 postgres
[myaction.yaml/tests]   🐳  docker exec cmd=[sh -e /var/run/act/workflow/0.sh] user= workdir=
| ping: postgres: Name or service not known

Documentation

In the docs it is stated that

The IP address of pgsql is on the same network as the container running the steps and there is no need for port binding (see the docker run —publish option for more information). The postgres:15 image exposes the PostgreSQL port 5432 and a client will be able to connect as shown in this example

Expected outcome

So I'd expect ping to succeed in this case.

# Test case Let's use this action ``` on: [push] jobs: tests: runs-on: ubuntu-latest container: node:12.16.1-stretch services: postgres: image: postgres:16.2 env: POSTGRES_USER: postgres POSTGRES_PASSWORD: "" POSTGRES_DB: postgres ports: - 5432:5432 # needed because the postgres container does not provide a healthcheck options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - run: ping -c 4 postgres ``` # Observed behaviour If I run this with `forgejo-runner exec --workflows myaction.yaml` I get ``` ... [myaction.yaml/tests] ⭐ Run Main ping -c 4 postgres [myaction.yaml/tests] 🐳 docker exec cmd=[sh -e /var/run/act/workflow/0.sh] user= workdir= | ping: postgres: Name or service not known ``` # Documentation In the docs it is stated that ``` The IP address of pgsql is on the same network as the container running the steps and there is no need for port binding (see the docker run —publish option for more information). The postgres:15 image exposes the PostgreSQL port 5432 and a client will be able to connect as shown in this example ``` # Expected outcome So I'd expect ping to succeed in this case.
Author

Seems like this was a problem in act and merged back in Aug 2023 https://github.com/nektos/act/issues/173

Seems like this was a problem in act and merged back in Aug 2023 https://github.com/nektos/act/issues/173
earl-warren added the
Kind/Bug
label 2024-04-04 04:32:54 +00:00
Owner

This usually happens when the config file sets the [container].network to something that is not "". For services to communicate the runner needs to create a dedicated network and [container].network: "" will allow it to do that.

Does that help?

This usually happens when the config file sets the `[container].network` to something that is not "". For services to communicate the runner needs to create a dedicated network and `[container].network: ""` will allow it to do that. Does that help?
Author

It is weird because I am running it locally.

In my forgejo runner the relevant config part is

container:
  # Specifies the network to which the container will connect.
  # Could be host, bridge or the name of a custom network.
  # If it's empty, create a network automatically.
  network: ""
  # Whether to create networks with IPv6 enabled. Requires the Docker daemon to be set up accordingly.
  # Only takes effect if "network" is set to "".
  enable_ipv6: false
  # Whether to use privileged mode or not when launching task containers (privileged mode is required for Docker-in-Docker).
  privileged: false

So looks like my network is ""

In the runner the result is the same.

It is weird because I am running it locally. In my forgejo runner the relevant config part is ``` container: # Specifies the network to which the container will connect. # Could be host, bridge or the name of a custom network. # If it's empty, create a network automatically. network: "" # Whether to create networks with IPv6 enabled. Requires the Docker daemon to be set up accordingly. # Only takes effect if "network" is set to "". enable_ipv6: false # Whether to use privileged mode or not when launching task containers (privileged mode is required for Docker-in-Docker). privileged: false ``` So looks like my network is "" In the runner the result is the same.
Member

Are you running docker, or podman with docker compat?

Are you running docker, or podman with docker compat?
Author

Docker

Arch linux in my desktop and debian (in proxmox) in the server that has the runner.

Docker Arch linux in my desktop and debian (in proxmox) in the server that has the runner.
Sign in to join this conversation.
No milestone
No project
No assignees
3 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: forgejo/runner#173
No description provided.