{"record":{"id":"280ba341cb07ecb9","repo":"docker/compose","slug":"could-not-get-created-time-for-service-s-image","errorCode":null,"errorMessage":"could not get created time for service's image","messagePattern":"could not get created time for service's image","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compose/watch.go","lineNumber":859,"sourceCode":"}\n\nfunc shouldIgnore(name string, ignore watch.PathMatcher) bool {\n\tshouldIgnore, _ := ignore.Matches(name)\n\t// ignore files that match any ignore pattern\n\treturn shouldIgnore\n}\n\n// gets the image creation time for a service\nfunc (s *composeService) imageCreatedTime(ctx context.Context, project *types.Project, serviceName string) (time.Time, error) {\n\tres, err := s.apiClient().ContainerList(ctx, client.ContainerListOptions{\n\t\tAll:     true,\n\t\tFilters: projectFilter(project.Name).Add(\"label\", serviceFilter(serviceName)),\n\t})\n\tif err != nil {\n\t\treturn time.Now(), err\n\t}\n\tif len(res.Items) == 0 {\n\t\treturn time.Now(), fmt.Errorf(\"could not get created time for service's image\")\n\t}\n\n\timg, err := s.apiClient().ImageInspect(ctx, res.Items[0].ImageID)\n\tif err != nil {\n\t\treturn time.Now(), err\n\t}\n\t// Need to get the oldest one?\n\ttimeCreated, err := time.Parse(time.RFC3339Nano, img.Created)\n\tif err != nil {\n\t\treturn time.Now(), err\n\t}\n\treturn timeCreated, nil\n}\n","sourceCodeStart":841,"sourceCodeEnd":873,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/compose/watch.go#L841-L873","documentation":"In `docker compose watch`, Compose looks up the service's running container to inspect its image creation time (used to detect stale images needing rebuild). This error is returned when `ContainerList` with the project + service label filters returns zero containers — the service is not running.","triggerScenarios":"Calling the watch path (`compose watch` / `up --watch`) for a service that has no containers: never started, already removed with `down`, or the project name label doesn't match. Note the function returns `time.Now()` alongside the error, and callers may ignore it.","commonSituations":"Running `docker compose watch` without `up` first (older flows), a container that crashed and exited between listing attempts, mismatched `COMPOSE_PROJECT_NAME`, or containers created by a different Compose version with different labels.","solutions":["Start the project first: `docker compose up -d` then `docker compose watch`","Verify the service has a container: `docker compose ps` and check the project/service labels","Ensure `COMPOSE_PROJECT_NAME` / working directory match the ones used to create the containers"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# ensure the service is up before watching\ndocker compose up -d && docker compose ps --status running | grep -q \"<service>\" && docker compose watch","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always `docker compose up -d` before `docker compose watch` in scripts","Pin COMPOSE_PROJECT_NAME so container labels always match the watch invocation","If a service container exits immediately, fix its entrypoint before enabling watch"],"tags":["compose","watch","container-not-found","docker-api"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}