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

Open Beginner friendly
#2,012 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
swift
Domain
cli

Research direction

Start at Parser.mount in Sources/Services/ContainerAPIService/Client/Parser.swift around line 371, then reproduce the issue with the provided container run command. Verify that a mount source or destination containing an equals sign is accepted as one value and that the existing invalid-directive behavior remains intact.

Written by the indexing model from the issue text.

Description

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
Dominant language
Swift
Stars
50.1k
Forks
1.8k
Avg merge
2d 2h
Merged PRs (30d)
19

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apple/container

All issues in apple/container

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.