docker/cli · error
image options are incompatible with type bind
Error message
image options are incompatible with type bind
What it means
Returned by handleBindToMount (cli/compose/convert/volume.go:129-130). Image options (image.subpath) select a path inside an image layer and only make sense for `type: image`; combining them with `type: bind` is contradictory, so the converter rejects it at cli/compose/convert/volume.go:130.
Solutions
- Remove the `image:` options block from the bind entry.
- If image subpath was intended, change `type:` to `image` and supply an image reference as `source`.
Example fix
# before
volumes:
- type: bind
source: /host/data
target: /data
image:
subpath: /app/assets
# after
volumes:
- type: bind
source: /host/data
target: /data Defensive patterns
Strategy: validation
Validate before calling
for i, v := range serviceVolumes {
if v.Type == "bind" && v.Image != nil {
return fmt.Errorf("service volume[%d] target=%q: type bind must not declare an image block", i, v.Target)
}
} Try / catch
mounts, err := convert.Volumes(serviceVolumes, stackVolumes, namespace)
if err != nil && strings.Contains(err.Error(), "image options are incompatible with type bind") {
return fmt.Errorf("compose config error: %w (remove the image: block from the bind entry)", err)
} Prevention
- Treat `type:` and its options block as a paired unit; change both together.
- Run `docker compose config` to catch mismatches before runtime.
When it happens
Trigger: ServiceVolumeConfig with Type=="bind" and Image!=nil passed to convertVolumeToMount().
Common situations: Converting an image-backed volume to a bind without removing the `image:` block; merge keys pulling in an image block.
Related errors
- cluster options are incompatible with type image
- invalid bind source, source cannot be empty
- volume options are incompatible with type bind
- tmpfs options are incompatible with type bind
- cluster options are incompatible with type bind
AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07).
Data as JSON: /api/errors/40fe6fb457d40177.
Report an issue: GitHub.
Appendix: source
Thrown at cli/compose/convert/volume.go:130
if volume.Image != nil {
result.ImageOptions = &mount.ImageOptions{
Subpath: volume.Image.Subpath,
}
}
return result, nil
}
func handleBindToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, error) {
result := createMountFromVolume(volume)
if volume.Source == "" {
return mount.Mount{}, errors.New("invalid bind source, source cannot be empty")
}
if volume.Volume != nil {
return mount.Mount{}, errors.New("volume options are incompatible with type bind")
}
if volume.Image != nil {
return mount.Mount{}, errors.New("image options are incompatible with type bind")
}
if volume.Tmpfs != nil {
return mount.Mount{}, errors.New("tmpfs options are incompatible with type bind")
}
if volume.Cluster != nil {
return mount.Mount{}, errors.New("cluster options are incompatible with type bind")
}
if volume.Bind != nil {
result.BindOptions = &mount.BindOptions{
Propagation: mount.Propagation(volume.Bind.Propagation),
}
}
return result, nil
}
func handleTmpfsToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, error) {
result := createMountFromVolume(volume)
View on GitHub (pinned to 4f84911bfe)