Interview Prep/GitHub Actions/Workflow Anatomy & Execution Model

How do you run a job inside a container image, and what changes?

IntermediateConceptWorkflow Anatomy & Execution Model
Answer
jobs:
  test:
    runs-on: ubuntu-24.04
    container:
      image: node:22-bookworm
      options: --user 1001
    steps:
      - uses: actions/checkout@v4
      - run: npm ci && npm test

All run steps and JavaScript actions execute inside that container; the workspace is mounted in. Works only on Linux runners. You lose some preinstalled tools from the host image, and the container may run as root, which can leave root-owned files in the workspace on self-hosted runners.

All GitHub Actions questions Roadmap: GitHub Actions

More on Workflow Anatomy & Execution Model