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.
error: could not find dockerfile: open /kaniko/buildcontext/Dockerfile:
no such file or directoryCommon 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
- Use
dir://with an absolute path to the checked-out sources. - Give the Dockerfile path relative to that context.
- Confirm the checkout step ran before Kaniko.
/kaniko/executor \
--context dir://${CI_PROJECT_DIR} \
--dockerfile Dockerfile \
--destination registry.example.com/app:latestUse 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.
/kaniko/executor \
--context git://github.com/org/repo.git#refs/heads/main \
--dockerfile Dockerfile --no-pushHow 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.