CI/CD & GitHub Actions (50 Qs)•Part 3: Enterprise Scale, Compliance & Production Hardening (Senior / Staff)
Containerized CI Jobs: Running workflow jobs directly inside Docker containers (`jobs.<job_id>.container`).
senior LevelMost AskedCode ExampleDocker & Containers
In Simple Words:
Instead of installing language runtimes, libraries, and native C-bindings on the VM host runner, container: executes all steps inside a dedicated Docker image, guaranteeing absolute environment reproducibility.
yaml
jobs:
build:
runs-on: ubuntu-latest
container:
image: golang:1.22-alpine
env:
CGO_ENABLED: '0'
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_PASSWORD: root
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- run: go test -v ./...