[Bug]: --mount and -v accept a relative container path and mount it at /<path>

オープン 初心者向け
#2,324 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@devops-thiago がすでに取り組んでいます。

2026年10月1日 から。

  • #2328 @devops-thiago による — オープン
  • #2362 @dajiaohuang による — マージされずにクローズ

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
86/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
swift
領域
cli

調査の方向性

Sources/Services/ContainerAPIService/Client/Parser.swift から始め、特に Parser.validateMount と Parser.tmpfsMounts を確認し、それぞれの mount 形式が destination をどのように検証しているかを比較してください。--mount、-v、--tmpfs について、相対、空、ドットベースのコンテナパスが既存の絶対パスエラーで一貫して拒否されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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

Give any mount form a relative path on the container side:

container run --rm --mount type=bind,source=/tmp,target=data alpine:latest sh -c 'ls -ld /data; mount | grep " /data "'

The container starts and the host folder is mounted at /data (image pull progress omitted):

drwxrwxrwt 1241 root     root         39712 Oct  1 17:26 /data
virtiofs on /data type virtiofs (rw,relatime)

The other forms are accepted the same way and also end up at /data:

container volume create evvol
container run --rm --mount type=volume,source=evvol,target=data alpine:latest ...   # ext4 on /data
container run --rm -v evvol:data alpine:latest ...                                  # ext4 on /data
container run --rm -v data alpine:latest ...                                        # anonymous volume, ext4 on /data
container run --rm --mount type=tmpfs,target=data alpine:latest ...                # tmpfs on /data

Paths with . and .. are accepted too. target=../x is mounted at /x, -v data:a/../../y at /y and target=./z at /z.

--tmpfs rejects the same path:

$ container run --rm --tmpfs data alpine:latest true
Error: data is not an absolute path

container create stores the value as typed. container inspect shows "destination" : "data" for a container whose running mount is /data.

A debug build of main at 0a48a1b accepts the same forms and rejects --tmpfs.

Problem description

Parser.validateMount is where parsed --mount and -v values are checked. For a filesystem or volume mount it only checks that the container path is not empty:

https://github.com/apple/container/blob/0a48a1bd/Sources/Services/ContainerAPIService/Client/Parser.swift#L654-L660

if fs.destination.isEmpty {
    throw ContainerizationError(.invalidArgument, message: "mount destination cannot be empty")
}

--tmpfs is stricter. Parser.tmpfsMounts rejects a relative path, added in #2103 for #2094, which says the destination "must be a non-empty absolute path". The same input is therefore an error for one flag and quietly reinterpreted by the others. A typo such as -v data:app/data mounts at /app/data without a word.

The container path is a location inside the container, and the OCI runtime spec requires it to be an absolute path (mounts[].destination in config.md). Every mount form should fail at parse time with the message --tmpfs already gives.

Environment
  • OS: macOS 26.6.2 (25G83)
  • Xcode: 26.6 (17F113)
  • Container: 1.5.0 (Homebrew), and main at 0a48a1b
Code of Conduct
  • I agree to follow this project's Code of Conduct
主要言語
Swift
スター
51k
フォーク
1.8k
平均マージ
2日 9時間
マージ済み PR(30日)
35

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apple/container のほかの issue

apple/container の issue をすべて見る

似ている issue

Swift の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。