{"record":{"id":"d00b41ef5f432a92","repo":"docker/compose","slug":"could-not-find-the-file-s-in-container-s","errorCode":null,"errorMessage":"could not find the file %s in container %s","messagePattern":"could not find the file (.+?) in container (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/dryrun/dryrunclient.go","lineNumber":192,"sourceCode":"func (d *DryRunClient) ContainerRestart(ctx context.Context, container string, options client.ContainerRestartOptions) (client.ContainerRestartResult, error) {\n\treturn client.ContainerRestartResult{}, nil\n}\n\nfunc (d *DryRunClient) ContainerStart(ctx context.Context, container string, options client.ContainerStartOptions) (client.ContainerStartResult, error) {\n\treturn client.ContainerStartResult{}, nil\n}\n\nfunc (d *DryRunClient) ContainerStop(ctx context.Context, container string, options client.ContainerStopOptions) (client.ContainerStopResult, error) {\n\treturn client.ContainerStopResult{}, nil\n}\n\nfunc (d *DryRunClient) ContainerUnpause(ctx context.Context, container string, options client.ContainerUnpauseOptions) (client.ContainerUnpauseResult, error) {\n\treturn client.ContainerUnpauseResult{}, nil\n}\n\nfunc (d *DryRunClient) CopyFromContainer(ctx context.Context, container string, options client.CopyFromContainerOptions) (client.CopyFromContainerResult, error) {\n\tif _, err := d.ContainerStatPath(ctx, container, client.ContainerStatPathOptions{Path: options.SourcePath}); err != nil {\n\t\treturn client.CopyFromContainerResult{}, fmt.Errorf(\"could not find the file %s in container %s\", options.SourcePath, container)\n\t}\n\treturn client.CopyFromContainerResult{\n\t\tContent: io.NopCloser(bytes.NewReader(nil)),\n\t}, nil\n}\n\nfunc (d *DryRunClient) CopyToContainer(ctx context.Context, container string, options client.CopyToContainerOptions) (client.CopyToContainerResult, error) {\n\treturn client.CopyToContainerResult{}, nil\n}\n\nfunc (d *DryRunClient) ImageBuild(ctx context.Context, reader io.Reader, options client.ImageBuildOptions) (client.ImageBuildResult, error) {\n\treturn client.ImageBuildResult{\n\t\tBody: io.NopCloser(bytes.NewReader(nil)),\n\t}, nil\n}\n\nfunc (d *DryRunClient) ImageInspect(ctx context.Context, imageName string, options ...client.ImageInspectOption) (client.ImageInspectResult, error) {\n\tcaller := getCallingFunction()","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/dryrun/dryrunclient.go#L174-L210","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# verify the path exists in the real container before dry-running a copy\ndocker compose exec <service> test -f /path/to/file && docker compose --dry-run cp <service>:/path/to/file ./dest","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["compose","dry-run","cp","file-not-found"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}