Can't connect to container services in container or host mode

Hi there,

I tried to set up a service container of localstack and postgres following the docs: About service containers - GitHub Docs

I keep running into connection refused error connecting via docker network alias (in containerized job).

In host-mode I got further with a test non-containerized step, the client is able to establish a connection, but immediately terminated. This is odd because I couldn’t repro this issue on my localbox with the same localstack version and config.

I’m hoping someone could point out something wrong with my setup. I’m interested in getting containerized steps to be able to connect via network aliases, e.g. “http://localstack:4572”.

name: build

on:
  pull_request:
    branches: [ main ]

  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    services:
      postgres:
        image: postgres:12.5
        env:
          POSTGRES_USER: $USER
        ports:
          - 5432:5432

      localstack:
        image: localstack/localstack:0.11.2
        env:
          SERVICES: ${SERVICES-s3}
          AWS_ACCESS_KEY_ID: test
          AWS_SECRET_ACCESS_KEY: test
          DEFAULT_REGION: us-west-2
        ports:
          - 4572:4572

    steps:
      - uses: actions/checkout@v2

# This step tries to connect to http://localstack:4572
      - name: Test
        uses: VaultVulp/action-pipenv@v2.0.1
        with:
          command: run python -m pytest --disable-pytest-warnings
        env:
          AWS_ACCESS_KEY_ID: test
          AWS_SECRET_ACCESS_KEY: test
          AWS_REGION: us-west-2
          DB_HOST: postgres
          S3_HOST: localstack

I also tried containerized job mode with a container: field set and it made no difference.

In containerized mode, I also tried taking out the ports mapping, per docs saying they’re not needed.

I also eliminated the possibility localstack just wasn’t ready for taking requests using a long sleep.

Thanks in advance.

hussein

Argh. Turns out it wasn’t a network issue. The network aliases work as advertised. I didn’t realize ${VAR-DEFAULT_VAL} is a bash syntax and not supported.

Closing the issue.