Is it possible to have two services talk to each other?

I am wanting to run some chromedriver/nightwatchJS end to end tests as part of my pipeline. I have a postgres and rest-api service defined. I need the rest-api service to be able to communicate to the postgres service but I cant see any way of doing so - is that sort of setup supported?

  run-e2e-tests-image:
    runs-on: ubuntu-latest
    name: E2E docker tests
    container: nightwatchjs/1.1

    services:
      postgres:
        image: postgres:13
        env:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
          POSTGRES_DB: db
        ports: ["5432:5432"]
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
      rest-api:
        image: ghcr.io/dabeeeenster/rest-api
        credentials:
          username: ${{ github.repository_owner }}
          password: ${{ secrets.REGISTRY_PAT }}
        env:
          DJANGO_ALLOWED_HOSTS: "*"
          DATABASE_URL: postgresql://postgres:postgres@localhost:5432/db
        ports: ["8000:8000"]

    steps:
      - name: Cloning repo
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Test with Chromedriver
        env:
          E2E_TEST_TOKEN_DEV: ${{ secrets.E2E_TEST_TOKEN_DEV }}
        run: |
          google-chrome --version
          node -v
          npm i
          export ENV=local; echo 'Setting env to' $ENV; npm run env
          npm run test

Services are Docker containers on the same network, so they should be able to talk to each other using the service names as hostnames. If you want the rest-api service to access the database you should only need to replace localhost with postgres in the DATABASE_URL. The port mappings on the runner VM won’t be available to the containers.