'host.docker.internal not working in github action

This is my simplified jobs.

jobs:
  build_and_test:
    runs-on: ubuntu-latest
    container:
      image: ubuntu:latest

    services:
      rod: # Rod browser
        image: ghcr.io/go-rod/rod
        options: >-
          --add-host=host.docker.internal:host-gateway
        ports:
          - 7317:7317

    steps:
      - name: test docker host
        run: host host.docker.internal

The test docker host step fails.

Host host.docker.internal not found: 3(NXDOMAIN)

I use that --add-host on local (Mac) and it works. It resolved to the host IP.

How to access the host from the docker container in GitHub action?

Thank you.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source