docker/cli · error

image options are incompatible with type tmpfs

Error message

image options are incompatible with type tmpfs

What it means

Returned by handleTmpfsToMount (cli/compose/convert/volume.go:158-159). image.subpath selects a path inside an image and is incompatible with an in-memory tmpfs, so the converter rejects a `image:` block on a tmpfs entry.

Solutions

  1. Delete the `image:` options block from the tmpfs entry.
  2. If image subpath was the goal, change `type:` to `image` and supply an image reference as source.

Example fix

# before
volumes:
  - type: tmpfs
    target: /cache
    image:
      subpath: /app/assets

# after
volumes:
  - type: tmpfs
    target: /cache
Defensive patterns

Strategy: validation

Validate before calling

for i, v := range serviceVolumes {
    if v.Type == "tmpfs" && v.Image != nil {
        return fmt.Errorf("service volume[%d] target=%q: type tmpfs 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 tmpfs") {
    return fmt.Errorf("compose config error: %w (remove the image: block from the tmpfs entry)", err)
}

Prevention

When it happens

Trigger: ServiceVolumeConfig with Type=="tmpfs" and Image!=nil passed to convertVolumeToMount().

Common situations: Refactoring an image-backed volume to tmpfs while leaving the `image:` block; template anchors merging an image block.

Related errors


AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07). Data as JSON: /api/errors/8066e480ec31cdb6. Report an issue: GitHub.

Appendix: source

Thrown at cli/compose/convert/volume.go:159

		}
	}
	return result, nil
}

func handleTmpfsToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, error) {
	result := createMountFromVolume(volume)

	if volume.Source != "" {
		return mount.Mount{}, errors.New("invalid tmpfs source, source must be empty")
	}
	if volume.Bind != nil {
		return mount.Mount{}, errors.New("bind options are incompatible with type tmpfs")
	}
	if volume.Volume != nil {
		return mount.Mount{}, errors.New("volume options are incompatible with type tmpfs")
	}
	if volume.Image != nil {
		return mount.Mount{}, errors.New("image options are incompatible with type tmpfs")
	}
	if volume.Cluster != nil {
		return mount.Mount{}, errors.New("cluster options are incompatible with type tmpfs")
	}
	if volume.Tmpfs != nil {
		result.TmpfsOptions = &mount.TmpfsOptions{
			SizeBytes: volume.Tmpfs.Size,
		}
	}
	return result, nil
}

func handleNpipeToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, error) {
	result := createMountFromVolume(volume)

	if volume.Source == "" {
		return mount.Mount{}, errors.New("invalid npipe source, source cannot be empty")
	}

View on GitHub (pinned to 4f84911bfe)