Skip to content
Latchkey

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 test

Gotchas

  • 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

Run this faster and cheaper on Latchkey managed runners. Start free →