devcontainers / devcontainers/cli

Podman: --userns=keep-id and --security-opt label=disable are never applied on the Docker Compose path

オープン
#1,300 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
3k
フォーク
457
平均マージ
13時間 17分
マージ済み PR(30日)
6

説明

## The problem

`getPodmanArgs()` — which adds `--security-opt label=disable` and, for a non-root `remoteUser`, `--userns=keep-id` — lives in `src/spec-node/singleContainer.ts` and is typed to `DevContainerFromDockerfileConfig | DevContainerFromImageConfig`. `src/spec-node/dockerCompose.ts` contains no podman handling at all, so a compose-based dev container on rootless podman gets neither flag.

Result: with rootless podman, the host user maps to container **root**, so a workspace bind mount appears as `root:0` inside and the non-root `remoteUser` cannot write to it.

## Reproduction

devcontainer CLI 0.87.0, podman 5.8.2 rootless, Linux. Two configs differing only in single-container vs compose, both `"remoteUser": "vscode"`, same base image.

`repro-sc/.devcontainer/devcontainer.json`

```json
{ "name": "sc", "image": "mcr.microsoft.com/devcontainers/base:ubuntu", "remoteUser": "vscode" }
```

`repro-co/.devcontainer/devcontainer.json` + `docker-compose.yml`

```json
{ "name": "co", "dockerComposeFile": "docker-compose.yml", "service": "app",
"workspaceFolder": "/workspace", "remoteUser": "vscode" }
```

```yaml
services:
app:
image: mcr.microsoft.com/devcontainers/base:ubuntu
command: sleep infinity
volumes: [ "..:/workspace:cached" ]
```

```
devcontainer up --workspace-folder repro-sc --docker-path $(which podman) --docker-compose-path $(which docker-compose)
devcontainer up --workspace-folder repro-co --docker-path $(which podman) --docker-compose-path $(which docker-compose)
```

`--docker-path`/`--docker-compose-path` are explicit only to make podman detection unambiguous; `lookupCLIVariant` correctly reports Podman in both runs.

## Result

```
podman inspect --format '{{.HostConfig.UsernsMode}} {{.HostConfig.SecurityOpt}}'
private [label=disable]

podman inspect --format '{{.HostConfig.UsernsMode}} {{.HostConfig.SecurityOpt}}'
(empty) []
```

Both workspaces are `dev:1000` on the host:

| | workspace owner inside | write as `remoteUser` |
|---|---|---|
| single container | `vscode:1000` | OK |
| compose | `root:0` | **Permission denied** |

## Expected

The compose path should apply the same podman handling as the single-container path — emitting the flags into the generated `docker-compose.devcontainer.*.yml` override (`userns_mode`, `security_opt`) for the primary service.

## Related but different

#1004 / #1018 (omit `keep-id` for root) and #1284 / #1285 (derive the mapping from the remote user's real UID/GID) all concern *how* `getPodmanArgs` should behave. This is that the compose path never calls it. Whatever #1285 settles for the mapping should presumably apply to both paths.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

src/spec-node/singleContainer.ts の getPodmanArgs() と、src/spec-node/dockerCompose.ts の Compose 処理を読んでから、再現手順にある 2 つの devcontainer up コマンドを実行します。生成された docker-compose.devcontainer.*.yml オーバーライドがプライマリサービスに userns_mode と security_opt を適用し、シングルコンテナーの Podman の動作と一致すれば完了です。

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

評価

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

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

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