Skip to content
Latchkey

Kaniko "context ... not found" (--context / --dockerfile) in CI

Kaniko takes an explicit --context (a directory, tarball, or remote source) and a --dockerfile path within it. If either points somewhere that does not exist in the job, Kaniko cannot start the build.

What this error means

Kaniko fails with "error resolving dockerfile path" or a message that the context could not be retrieved, before any build stage runs.

kaniko
error: could not find dockerfile: open /kaniko/buildcontext/Dockerfile:
no such file or directory

Common causes

The --context is not where the checkout landed

The context must point at the checked-out sources. A default of the current directory can be empty if the job did not clone into it.

The --dockerfile path is relative to the wrong root

Kaniko resolves the Dockerfile inside the context. A path relative to the repo root while the context is a subdirectory will not resolve.

How to fix it

Point --context at the checkout and --dockerfile inside it

  1. Use dir:// with an absolute path to the checked-out sources.
  2. Give the Dockerfile path relative to that context.
  3. Confirm the checkout step ran before Kaniko.
Terminal
/kaniko/executor \
  --context dir://${CI_PROJECT_DIR} \
  --dockerfile Dockerfile \
  --destination registry.example.com/app:latest

Use a git or tar context when there is no local checkout

Kaniko can pull the context from git or a tarball if the job does not clone locally.

Terminal
/kaniko/executor \
  --context git://github.com/org/repo.git#refs/heads/main \
  --dockerfile Dockerfile --no-push

How to prevent it

  • Always pass an explicit --context with an absolute path.
  • Keep --dockerfile relative to the context, not the repo root.
  • Ensure the checkout step completes before the executor runs.

Frequently asked questions

What causes ""context ... not found""?
The context must point at the checked-out sources. A default of the current directory can be empty if the job did not clone into it.
How do I fix "context ... not found"?
Point --context at the checkout and --dockerfile inside it

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card