Skip to content

Bind.parse() fails to handle Windows-style absolute paths with drive letters #2479

@zazhiii

Description

@zazhiii

Description

When using Bind.parse() on Windows, if the bind string contains an absolute path with a drive letter (e.g. G:/path/to/folder:/container/path:rw), it fails with IllegalArgumentException due to incorrect parsing of the colon : in the drive letter.

Example

String serialized = "G:/zzcoder-judger-work/304bdf33-8970-4e06-a3d1-e10b7f162960:/app:rw";
Bind bind = Bind.parse(serialized);

Result

java.lang.IllegalArgumentException: Error parsing Bind 'G:/zzcoder-judger-work/304bdf33-8970-4e06-a3d1-e10b7f162960:/app:rw'
	at com.github.dockerjava.api.model.Bind.parse(Bind.java:...)
...

This is because Bind.parse() internally uses split(":(?!\\\\)"), which incorrectly splits the drive letter (G:) as a separate part, resulting in a malformed array of parts like:

parts[0] = "G"
parts[1] = "/zzcoder-judger-work/..."
parts[2] = "/app"
parts[3] = "rw"

Thus, the method throws IllegalArgumentException.

Expected Behavior

Bind.parse() should handle valid Windows-style absolute paths that contain a colon (:) as part of the drive letter (e.g. C:/..., D:/..., etc.) and not split them incorrectly.

Environment

  • OS: Windows 11
  • docker-java version: 3.4.0
  • Java version: 17

Suggested Fix

Consider improving the parser logic in Bind.parse() to:

  • Recognize Windows drive letters and handle them gracefully.
  • Avoid blindly splitting on : without checking the context.
  • Possibly introduce an overloaded method or helper for cross-platform compatibility.

Thanks for your support and for maintaining this useful library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions