docker/compose · error

no container found for service %q

Error message

no container found for service %q

What it means

Error "no container found for service %q" thrown in docker/compose.

Source

Thrown at pkg/compose/cp.go:136

	switch {
	case options.Index > 0:
		ctr, err := s.getSpecifiedContainer(ctx, projectName, oneOffExclude, true, serviceName, options.Index)
		if err != nil {
			return nil, err
		}
		return append(containers, ctr), nil
	default:
		withOneOff := oneOffExclude
		if options.All {
			withOneOff = oneOffInclude
		}
		containers, err = s.getContainers(ctx, projectName, withOneOff, true, serviceName)
		if err != nil {
			return nil, err
		}

		if len(containers) < 1 {
			return nil, fmt.Errorf("no container found for service %q", serviceName)
		}
		if direction == fromService {
			return containers[:1], err
		}
		return containers, err
	}
}

func (s *composeService) copyToContainer(ctx context.Context, containerID string, srcPath string, dstPath string, opts api.CopyOptions) error {
	var err error
	if srcPath != "-" {
		// Get an absolute source path.
		srcPath, err = resolveLocalPath(srcPath)
		if err != nil {
			return err
		}
	}

View on GitHub (pinned to ddc4b044b6)

Solutions

  1. Start the service first with docker compose up -d <service> before copying files to or from it.
  2. Verify the service name is correct with docker compose ps and that its container has not been removed.

When it happens

Trigger: 'docker compose cp' could not find a running (or existing) container for the named service in the project.

Common situations: The service is stopped or never started, the project name differs from the one used to bring the stack up, or a container index is out of range.


AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15). Data as JSON: /api/errors/2b83a4c098106517. Report an issue: GitHub.