Skip to content
Latchkey

How to Use Executors in CircleCI

Executors name a reusable execution environment - Docker image, Linux VM, or macOS - that multiple jobs reference instead of redefining.

Declare named environments under the top-level executors: key, then set executor: on each job. Executors can take parameters for image or resource class.

Define and reuse an executor

One executor definition serves several jobs; parameters let you vary the image.

.circleci/config.yml
version: 2.1
executors:
  node:
    parameters:
      tag:
        type: string
        default: "20.11"
    docker:
      - image: cimg/node:<< parameters.tag >>
    resource_class: medium

jobs:
  test:
    executor: node
    steps:
      - checkout
      - run: npm ci && npm test
  build:
    executor:
      name: node
      tag: "22.2"
    steps:
      - run: npm run build

Gotchas

  • Executor types differ: docker is fast and isolated, machine runs a full VM (needed for privileged Docker), macos for Apple builds.
  • resource_class sets CPU/RAM and affects credit cost; right-size it.
  • Parameterized executors keep one definition while varying the image or class per job.

Key takeaways

  • Executors define reusable execution environments.
  • Pick docker, machine, or macos to match the workload.
  • resource_class controls compute and billing.

Related guides

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