CircleCI Cannot Use Environment Variable in Image Name
The docker.image field is resolved at config-processing time, before any job shell runs, so shell environment variables do not interpolate there. Only pipeline parameters and certain pipeline values expand in image names.
What this error means
The job tries to pull an image with the literal variable in the name, or fails because the image tag did not expand.
circleci
Error: image "cimg/node:$NODE_VERSION" not found.
Environment variables are not interpolated in the docker image field.Common causes
Shell env var used in image field
NODE_VERSION from a context or env is not available when the image is resolved.
Expecting runtime interpolation
Image resolution happens before the job shell exists, so runtime values cannot be used.
How to fix it
Use a pipeline parameter
Parameterize the image tag with a declared parameter, which is resolved at config time.
.circleci/config.yml
parameters:
node_version:
type: string
default: '20.11'
jobs:
build:
docker:
- image: cimg/node:<< pipeline.parameters.node_version >>
steps:
- run: node --versionHow to prevent it
- Use pipeline parameters, not shell env vars, in image names.
- Resolve image tags at config-processing time.
- Pin image versions explicitly where possible.
Related guides
CircleCI "parameter X is not declared" ErrorFix CircleCI parameter X is not declared - a job, command, or executor uses a parameter that was never declar…
CircleCI Machine Executor Image Not FoundFix CircleCI machine executor image not found - an invalid, deprecated, or removed machine image tag, or a tr…
CircleCI Docker Image Pull Rate Limit ExceededFix CircleCI jobs failing on Docker Hub pull rate limits - authenticate the pull or mirror the image so trans…