How to Run a Container Job in Azure Pipelines
The container key runs every step of a job inside a Docker image, pinning your toolchain regardless of the agent OS.
Set container: on a job (Linux agents) to run all its steps inside that image. Use a resources.containers entry for private registries or extra options.
Run steps in a pinned image
Every step in this job runs inside node:20-bullseye.
azure-pipelines.yml
resources:
containers:
- container: node20
image: node:20-bullseye
jobs:
- job: Test
pool:
vmImage: ubuntu-latest
container: node20
steps:
- script: node --version && npm ci && npm testGotchas
- Container jobs require a Linux agent host; Windows container jobs have separate constraints.
- For private images, add an
endpoint:(a Docker registry service connection) to the container resource. - The agent mounts the workspace into the container, so steps see your checked-out repo.
Related guides
How to Register Self-Hosted Agents in Azure PipelinesSet up a self-hosted agent for Azure Pipelines - create an agent pool, register the agent with a PAT, and tar…
How to Use a Matrix Strategy in Azure PipelinesFan a job out across versions or configurations in Azure Pipelines with strategy.matrix, named legs, maxParal…