{"record":{"id":"e32ee458a0dac2d8","repo":"docker/cli","slug":"invalid-mount-config-for-type-bind-field-source","errorCode":null,"errorMessage":"invalid mount config for type \"bind\": field Source must not be empty","messagePattern":"invalid mount config for type \"bind\": field Source must not be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/loader/loader.go","lineNumber":493,"sourceCode":"\t\t\tenvVars = append(envVars, fileVars...)\n\t\t}\n\t\tupdateEnvironment(environment,\n\t\t\topts.ConvertKVStringsToMapWithNil(envVars), lookupEnv)\n\t}\n\n\tupdateEnvironment(environment, serviceConfig.Environment, lookupEnv)\n\tserviceConfig.Environment = environment\n\treturn nil\n}\n\nfunc resolveVolumePaths(volumes []types.ServiceVolumeConfig, workingDir string, lookupEnv template.Mapping) error {\n\tfor i, volume := range volumes {\n\t\tif volume.Type != \"bind\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tif volume.Source == \"\" {\n\t\t\treturn errors.New(`invalid mount config for type \"bind\": field Source must not be empty`)\n\t\t}\n\n\t\tfilePath := expandUser(volume.Source, lookupEnv)\n\t\t// Check if source is an absolute path (either Unix or Windows), to\n\t\t// handle a Windows client with a Unix daemon or vice-versa.\n\t\t//\n\t\t// Note that this is not required for Docker for Windows when specifying\n\t\t// a local Windows path, because Docker for Windows translates the Windows\n\t\t// path into a valid path within the VM.\n\t\tif !path.IsAbs(filePath) && !isAbs(filePath) {\n\t\t\tfilePath = absPath(workingDir, filePath)\n\t\t}\n\t\tvolume.Source = filePath\n\t\tvolumes[i] = volume\n\t}\n\treturn nil\n}\n","sourceCodeStart":475,"sourceCodeEnd":511,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/loader/loader.go#L475-L511","documentation":"Thrown by resolveVolumePaths when iterating service volumes and a volume with Type == \"bind\" has an empty Source field. A bind mount requires a host path to bind into the container; without a source there is nothing to mount. The check happens during path resolution after the compose document is parsed into typed config.","triggerScenarios":"A service declares a volume entry with type: bind (or a long-form volumes entry missing the source) but no source path. Mixing a short-syntax anonymous volume (intended as a named/anonymous volume) while forcing type: bind. A templating step that omits the source when a variable is unset.","commonSituations":"Authoring 'volumes: - type: bind target: /data' and forgetting the 'source:' line. An env-var-driven source like 'source: ${HOST_PATH}' where HOST_PATH is empty, leaving source blank after interpolation. Copying a named-volume snippet and switching type to bind without adding a host path.","solutions":["Add a concrete host path to the bind volume's source field (absolute path recommended).","If you wanted a Docker-managed volume rather than a host bind, remove 'type: bind' (or set 'type: volume') and reference a named volume declared under the top-level 'volumes:' key.","Ensure any interpolation variable used for source is actually set, or provide a default: 'source: ${HOST_PATH:-./data}'."],"exampleFix":"# before\nservices:\n  app:\n    volumes:\n      - type: bind\n        target: /data\n# after\nservices:\n  app:\n    volumes:\n      - type: bind\n        source: ./data\n        target: /data","handlingStrategy":"validation","validationCode":"// Reject bind volumes with an empty source before calling loader.Load.\nfor _, svc := range config.Services {\n    for _, v := range svc.Volumes {\n        if v.Type == \"bind\" && strings.TrimSpace(v.Source) == \"\" {\n            return fmt.Errorf(\"service %q has a bind volume with empty source\", svc.Name)\n        }\n    }\n}","typeGuard":"func hasBindSource(v types.ServiceVolumeConfig) bool {\n    return v.Type != \"bind\" || v.Source != \"\"\n}","tryCatchPattern":null,"preventionTips":["Always specify 'source' for long-form bind volumes.","Provide interpolation defaults: ${HOST_PATH:-./data}.","Run 'docker compose config' to expand and inspect resolved volume sources."],"tags":["compose","volumes","bind-mount","validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}