Skip to content
Latchkey

Dockerfile "Please provide a source image with from prior to" in CI

A build instruction such as RUN or COPY appears before any FROM, so Docker has no base image to run it against. FROM must be the first instruction, after any leading ARG.

What this error means

docker build fails immediately with "Please provide a source image with from prior to run" (the trailing word matches the offending instruction).

docker build
Please provide a source image with `from` prior to run

Common causes

An instruction precedes FROM

A RUN, COPY, or similar instruction is placed above the FROM line, so there is no image context yet.

A commented-out or missing FROM

The FROM line was removed or commented, leaving the first real instruction with no base.

How to fix it

Make FROM the first instruction

Put FROM first; only ARG used by FROM may precede it.

Dockerfile
ARG NODE_VERSION=20
FROM node:${NODE_VERSION}-slim
RUN npm ci

Restore a missing FROM

  1. Confirm a real FROM <image> line exists and is not commented.
  2. Move any stray instructions below it.
  3. Re-run the build.

How to prevent it

  • Start every Dockerfile (and every stage) with FROM.
  • Only place ARG used by FROM above it.
  • Lint Dockerfiles to catch instructions before FROM.

Frequently asked questions

What causes ""provide a source image with from prior to""?
A RUN, COPY, or similar instruction is placed above the FROM line, so there is no image context yet.
How do I fix "provide a source image with from prior to"?
Put FROM first; only ARG used by FROM may precede it.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card