What are service containers and how does networking differ between container jobs and host jobs?
IntermediateConceptWorkflow Anatomy & Execution Model
Answer
services start sidecar containers (databases, Redis) for the job, with health-checked startup via options.
services:
postgres:
image: postgres:16
env: { POSTGRES_PASSWORD: test }
ports: ["5432:5432"]
options: >-
--health-cmd "pg_isready -U postgres" --health-interval 5s --health-retries 10
If the job runs on the host, reach the service at localhost:5432 through the mapped port. If the job runs in a container, both share a Docker network and you use the service name: postgres:5432, no port mapping needed.
More on Workflow Anatomy & Execution Model
Define workflow, run, job, step, action and runner in one line each.BeginnerWhat is the minimum valid workflow file?BeginnerWhere must workflow files live, and does the file extension matter?BeginnerWhich version of the workflow file does GitHub use for a given run?IntermediateWhat does a GitHub-hosted runner give you at the start of a job?BeginnerShould you use `ubuntu-latest` or `ubuntu-24.04`?Beginner