docker/compose · warning
could not find the file %s in container %s
Error message
could not find the file %s in container %s
What it means
Dry-run mode (`docker compose --dry-run`) simulates API calls. `CopyFromContainer` first stats the source path via `ContainerStatPath`; if the stat fails, it reports the file as not found in the container. Since dry-run containers are simulated, this usually reflects a path that does not exist on the host or a simulated container that was never created.
Source
Thrown at pkg/dryrun/dryrunclient.go:192
func (d *DryRunClient) ContainerRestart(ctx context.Context, container string, options client.ContainerRestartOptions) (client.ContainerRestartResult, error) {
return client.ContainerRestartResult{}, nil
}
func (d *DryRunClient) ContainerStart(ctx context.Context, container string, options client.ContainerStartOptions) (client.ContainerStartResult, error) {
return client.ContainerStartResult{}, nil
}
func (d *DryRunClient) ContainerStop(ctx context.Context, container string, options client.ContainerStopOptions) (client.ContainerStopResult, error) {
return client.ContainerStopResult{}, nil
}
func (d *DryRunClient) ContainerUnpause(ctx context.Context, container string, options client.ContainerUnpauseOptions) (client.ContainerUnpauseResult, error) {
return client.ContainerUnpauseResult{}, nil
}
func (d *DryRunClient) CopyFromContainer(ctx context.Context, container string, options client.CopyFromContainerOptions) (client.CopyFromContainerResult, error) {
if _, err := d.ContainerStatPath(ctx, container, client.ContainerStatPathOptions{Path: options.SourcePath}); err != nil {
return client.CopyFromContainerResult{}, fmt.Errorf("could not find the file %s in container %s", options.SourcePath, container)
}
return client.CopyFromContainerResult{
Content: io.NopCloser(bytes.NewReader(nil)),
}, nil
}
func (d *DryRunClient) CopyToContainer(ctx context.Context, container string, options client.CopyToContainerOptions) (client.CopyToContainerResult, error) {
return client.CopyToContainerResult{}, nil
}
func (d *DryRunClient) ImageBuild(ctx context.Context, reader io.Reader, options client.ImageBuildOptions) (client.ImageBuildResult, error) {
return client.ImageBuildResult{
Body: io.NopCloser(bytes.NewReader(nil)),
}, nil
}
func (d *DryRunClient) ImageInspect(ctx context.Context, imageName string, options ...client.ImageInspectOption) (client.ImageInspectResult, error) {
caller := getCallingFunction()View on GitHub (pinned to ddc4b044b6)
Solutions
- Check the source path spelling and that it exists in the real container (`docker compose exec <svc> ls <path>`)
- Run the copy command without `--dry-run` — dry-run cannot verify file contents in a container that isn't there
Defensive patterns
Strategy: validation
Validate before calling
# verify the path exists in the real container before dry-running a copy docker compose exec <service> test -f /path/to/file && docker compose --dry-run cp <service>:/path/to/file ./dest
Prevention
- Treat --dry-run output as a plan, not a filesystem validation
- Check source paths with `docker compose exec ... test -f` in scripts that later copy for real
When it happens
Trigger: A command run with `--dry-run` that copies files out of a container (e.g. `docker compose --dry-run cp <svc>:<path> ./dest`) where the stat of `options.SourcePath` fails in the simulated client.
Common situations: Using `compose cp` in dry-run with a typo'd source path; dry-running a workflow where the container doesn't actually exist; expecting dry-run to validate real container contents it cannot see.
Related errors
- source can not be empty
- destination can not be empty
- interactive run is not supported in dry-run mode
- interactive exec is not supported in dry-run mode
- invalid scale specifier: %s
AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15).
Data as JSON: /api/errors/d00b41ef5f432a92.
Report an issue: GitHub.