{"record":{"id":"a2d1e5a4241d460a","repo":"docker/compose","slug":"cannot-share-volume-with-service-s-container-mis","errorCode":null,"errorMessage":"cannot share volume with service %s: container missing","messagePattern":"cannot share volume with service (.+?): container missing","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compose/convergence.go","lineNumber":86,"sourceCode":"\t\treturn err\n\t}\n\treturn resolveSharedNamespaces(service, containersByService)\n}\n\nfunc resolveVolumeFrom(service *types.ServiceConfig, containersByService map[string]Containers) error {\n\tfor i, vol := range service.VolumesFrom {\n\t\tspec := strings.Split(vol, \":\")\n\t\tif len(spec) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif spec[0] == \"container\" {\n\t\t\tservice.VolumesFrom[i] = spec[1]\n\t\t\tcontinue\n\t\t}\n\t\tname := spec[0]\n\t\tdependencies := containersByService[name]\n\t\tif len(dependencies) == 0 {\n\t\t\treturn fmt.Errorf(\"cannot share volume with service %s: container missing\", name)\n\t\t}\n\t\tservice.VolumesFrom[i] = dependencies.sorted()[0].ID\n\t}\n\treturn nil\n}\n\nfunc resolveSharedNamespaces(service *types.ServiceConfig, containersByService map[string]Containers) error {\n\tif name := getDependentServiceFromMode(service.NetworkMode); name != \"\" {\n\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 {","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/compose/convergence.go#L68-L104","documentation":"resolveVolumeFrom rewrites each volumes_from entry that references a service name into a container ID. It looks the dependency up in containersByService; if the referenced service has zero containers, there is nothing to share volumes from, so convergence aborts with this error. Entries of the form 'container:<id>' pass through untouched.","triggerScenarios":"`docker compose up` where a service declares `volumes_from: [otherservice]` but otherservice has no running/created containers — dependency failed to create, was removed mid-run, or is listed without being part of this project's started set.","commonSituations":"Missing depends_on so the dependency isn't created yet when the dependent converges; dependency crashed immediately and its container was cleaned up (--rm one-off behavior); typo in the volumes_from service name.","solutions":["Add `depends_on` for the shared-from service so it is created first, and confirm it starts successfully","Check the dependency actually exists: `docker compose ps <dep>`; fix crashes or name typos","If sharing data rather than a container is the goal, switch to a named volume mounted by both services"],"exampleFix":"# before\nservices:\n  data:\n    image: busybox\n  app:\n    volumes_from:\n      - data   # may not exist yet\n\n# after\nservices:\n  data:\n    image: busybox\n  app:\n    depends_on:\n      - data\n    volumes_from:\n      - data","handlingStrategy":"validation","validationCode":"for _, vf := range svc.VolumesFrom {\n    name := strings.SplitN(vf, \":\", 2)[0]\n    if name == \"container\" { continue }\n    if len(containersByService[name]) == 0 {\n        return fmt.Errorf(\"volumes_from target %s has no containers\", name)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare depends_on for every volumes_from source","Prefer named volumes shared between services over volumes_from for new designs"],"tags":["volumes-from","dependencies","convergence","containers"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}