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 buildGotchas
- Executor types differ:
dockeris fast and isolated,machineruns a full VM (needed for privileged Docker),macosfor Apple builds. resource_classsets 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_classcontrols compute and billing.
Related guides
How to Use Orbs in CircleCIUse orbs in CircleCI to pull in reusable commands, jobs, and executors from the registry, cutting boilerplate…
How to Use a Docker Executor with Registry Auth in CircleCIAuthenticate the CircleCI docker executor to a private registry with auth: under the image, using project env…