docker/cli · error

empty section between colons

Error message

empty section between colons

What it means

Returned by populateFieldFromBuffer (internal/volumespec/volumespec.go:60) during Parse when a colon (or end-of-spec marker) is encountered but the character buffer is empty. This means two colons appear back-to-back (::), or the spec begins or ends with a colon, producing an empty segment where a path/name is expected.

Solutions

  1. Inspect the volume spec for double colons (::) or leading/trailing colons and remove them.
  2. Validate the spec format: a volume spec should have at most two colons separating source, target, and options — each segment must be non-empty.

Example fix

// before: double colon in spec
// docker run -v /foo::/bar nginx

// after: single colon
// docker run -v /foo:/bar nginx
Defensive patterns

Strategy: validation

Validate before calling

func validateVolumeSpecFormat(spec string) error {
    if strings.HasPrefix(spec, ":") || strings.HasSuffix(spec, ":") {
        return fmt.Errorf("volume spec must not start or end with a colon: %s", spec)
    }
    if strings.Contains(spec, "::") {
        return fmt.Errorf("volume spec must not contain empty segments (::): %s", spec)
    }
    return nil
}

Try / catch

vol, err := volumespec.Parse(spec)
if err != nil {
    if strings.Contains(err.Error(), "empty section between colons") {
        return fmt.Errorf("malformed volume spec %q: remove empty segments (::)", spec)
    }
    return err
}

Prevention

When it happens

Trigger: volumespec.Parse is called with a spec containing '::' (e.g., '/foo::/bar'), a leading colon (':/bar'), or a trailing colon ('/foo:'). The parser accumulates characters into a buffer; when it hits a delimiter with an empty buffer, this error fires.

Common situations: Typo producing double colons in a volume mount spec, copy-paste error, malformed compose volume string, accidental leading/trailing colon from string concatenation.

Related errors


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

Appendix: source

Thrown at internal/volumespec/volumespec.go:60

			buffer = buffer[:0] // reset, but reuse capacity
		default:
			buffer = append(buffer, char)
		}
	}

	populateType(&volume)
	return volume, nil
}

func isWindowsDrive(buffer []rune, char rune) bool {
	return char == ':' && len(buffer) == 1 && unicode.IsLetter(buffer[0])
}

func populateFieldFromBuffer(char rune, buffer []rune, volume *VolumeConfig) error {
	strBuffer := string(buffer)
	switch {
	case len(buffer) == 0:
		return errors.New("empty section between colons")
	// Anonymous volume
	case volume.Source == "" && char == endOfSpec:
		volume.Target = strBuffer
		return nil
	case volume.Source == "":
		volume.Source = strBuffer
		return nil
	case volume.Target == "":
		volume.Target = strBuffer
		return nil
	case char == ':':
		return errors.New("too many colons")
	}
	for option := range strings.SplitSeq(strBuffer, ",") {
		switch option {
		case "ro":
			volume.ReadOnly = true
		case "rw":

View on GitHub (pinned to 4f84911bfe)