Skip to content

[Bug]: --mount rejects a directive whose value contains "=" #2012

Description

@devops-thiago

I have done the following

  • I have searched the existing issues
  • If possible, I've reproduced the issue using the 'main' branch of this project

Steps to reproduce

Run a container with a mount whose source path contains an equals sign:

container run --rm --mount type=virtiofs,source=/tmp/a=b,destination=/mnt alpine true

The command fails with:

invalid directive format missing value source=/tmp/a=b in type=virtiofs,source=/tmp/a=b,destination=/mnt

Creating the directory first makes no difference, because the failure happens while parsing the flag.

Problem description

Parser.mount splits each comma-separated directive on = with maxSplits: 2:

https://github.com/apple/container/blob/main/Sources/Services/ContainerAPIService/Client/Parser.swift#L371

In Swift, maxSplits counts splits rather than resulting elements, so a value that itself contains = produces three components:

"source=/tmp/a=b".split(separator: "=", maxSplits: 2)
// ["source", "/tmp/a", "b"]

The code then requires exactly two components and throws otherwise:

if keyVal.count != 2 {
    throw ContainerizationError(.invalidArgument, message: "invalid directive format missing value \(part) in \(mount)")
}

A directive should split on the first = only, so that everything after it is the value. maxSplits: 1 produces ["source", "/tmp/a=b"].

Equals signs are legal in POSIX path names, so any bind mount whose source or destination contains one is currently unusable.

This is the same defect that #1978 and #1999 fix for Parser.labels. Neither touches Parser.mount, so mounts remain affected.

Environment

  • OS: macOS 26.5.2 (25F84)
  • Xcode: 26.6 (17F113)
  • Container: main at 07ff3c0 (also present in 1.1.0)

Code of Conduct

  • I agree to follow this project's Code of Conduct

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