{"record":{"id":"6ab6143ab4e3fdde","repo":"docker/compose","slug":"cannot-share-pid-namespace-with-service-s-contai","errorCode":null,"errorMessage":"cannot share PID namespace with service %s: container missing","messagePattern":"cannot share PID namespace with service (.+?): container missing","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compose/convergence.go","lineNumber":113,"sourceCode":"\t\tdependencies := containersByService[name]\n\t\tif len(dependencies) == 0 {\n\t\t\treturn fmt.Errorf(\"cannot share network namespace with service %s: container missing\", name)\n\t\t}\n\t\tservice.NetworkMode = types.ContainerPrefix + dependencies.sorted()[0].ID\n\t}\n\n\tif name := getDependentServiceFromMode(service.Ipc); name != \"\" {\n\t\tdependencies := containersByService[name]\n\t\tif len(dependencies) == 0 {\n\t\t\treturn fmt.Errorf(\"cannot share IPC namespace with service %s: container missing\", name)\n\t\t}\n\t\tservice.Ipc = types.ContainerPrefix + dependencies.sorted()[0].ID\n\t}\n\n\tif name := getDependentServiceFromMode(service.Pid); name != \"\" {\n\t\tdependencies := containersByService[name]\n\t\tif len(dependencies) == 0 {\n\t\t\treturn fmt.Errorf(\"cannot share PID namespace with service %s: container missing\", name)\n\t\t}\n\t\tservice.Pid = types.ContainerPrefix + dependencies.sorted()[0].ID\n\t}\n\n\treturn nil\n}\n\nfunc getContainerName(projectName string, service types.ServiceConfig, number int) string {\n\tname := getDefaultContainerName(projectName, service.Name, strconv.Itoa(number))\n\tif service.ContainerName != \"\" {\n\t\tname = service.ContainerName\n\t}\n\treturn name\n}\n\nfunc getDefaultContainerName(projectName, serviceName, index string) string {\n\treturn strings.Join([]string{projectName, serviceName, index}, api.Separator)\n}","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/compose/convergence.go#L95-L131","documentation":"The PID arm of resolveSharedNamespaces: `pid: \"service:<name>\"` needs a live container of that service to rewrite the reference into container:<id>. An empty containersByService entry for the named dependency makes the PID namespace unshareable and stops convergence with this error.","triggerScenarios":"`docker compose up` with `pid: service:sidecar` where the sidecar service has no containers — not created in this run, removed, or crashed before the dependent converged.","commonSituations":"Monitoring/signal-forwarding designs (share PID with an init or supervisor sidecar); starting the dependent alone with `docker compose up app`; sidecar OOM-killed at startup so its container vanishes.","solutions":["Start both services together or add `depends_on` so the PID provider exists first","Inspect why the provider is absent: `docker compose ps -a <provider>`, `docker compose logs <provider>`","If you only need a PID namespace without a specific peer, use `pid: host` or a pod-like single-container design instead"],"exampleFix":"# before\nservices:\n  supervisor:\n    image: busybox\n  app:\n    pid: \"service:supervisor\"\n\n# after\nservices:\n  supervisor:\n    image: busybox\n  app:\n    depends_on: [supervisor]\n    pid: \"service:supervisor\"","handlingStrategy":"validation","validationCode":"if name := getDependentServiceFromMode(svc.Pid); name != \"\" {\n    if len(containersByService[name]) == 0 {\n        return fmt.Errorf(\"pid service:%s has no containers\", name)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure PID providers are created before dependents (depends_on + healthcheck)","Watch provider logs for OOM kills that silently remove the namespace source"],"tags":["pid","namespaces","dependencies","convergence"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}