docker/compose · error

container %s exited (%d)

Error message

container %s exited (%d)

What it means

Error "container %s exited (%d)" thrown in docker/compose.

Source

Thrown at pkg/compose/convergence.go:480

		if !ok {
			linkName = externalLink
		}
		links = append(links, format(externalLink, linkName))
	}
	return links, nil
}

func (s *composeService) isServiceHealthy(ctx context.Context, containers Containers, fallbackRunning bool) (bool, error) {
	for _, c := range containers {
		res, err := s.apiClient().ContainerInspect(ctx, c.ID, client.ContainerInspectOptions{})
		if err != nil {
			return false, err
		}
		ctr := res.Container
		name := ctr.Name[1:]

		if ctr.State.Status == container.StateExited {
			return false, fmt.Errorf("container %s exited (%d)", name, ctr.State.ExitCode)
		}

		noHealthcheck := ctr.Config.Healthcheck == nil || (len(ctr.Config.Healthcheck.Test) > 0 && ctr.Config.Healthcheck.Test[0] == "NONE")
		if noHealthcheck && fallbackRunning {
			// Container does not define a health check, but we can fall back to "running" state
			return ctr.State != nil && ctr.State.Status == container.StateRunning, nil
		}

		if ctr.State == nil || ctr.State.Health == nil {
			return false, fmt.Errorf("container %s has no healthcheck configured", name)
		}
		switch ctr.State.Health.Status {
		case container.Healthy:
			// Continue by checking the next container.
		case container.Unhealthy:
			return false, fmt.Errorf("container %s is unhealthy", name)
		case container.Starting:
			return false, nil

View on GitHub (pinned to ddc4b044b6)

Solutions

  1. Check the exited container's logs with docker compose logs <service> to find why it stopped.
  2. Fix the application error or configuration causing the non-zero exit, then run docker compose up again.
  3. If the exit is expected for a one-shot task, remove it from the services started with up or adjust depends_on conditions.

When it happens

Trigger: A container that was expected to keep running (or to exit 0) exited with the reported non-zero code while compose was waiting for it, e.g. with --abort-on-container-exit or --wait.

Common situations: The container's main process crashed, received a fatal signal, or exited early due to a configuration or application error. Inspect the container logs for the root cause.


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