Skip to content

Commit 7c59dba

Browse files
committed
Fix: --uidmap/--gidmap conflict with --userns (#10954)
1 parent da16ca9 commit 7c59dba

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/spec-node/singleContainer.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ while sleep 1 & wait $!; do :; done`, '-']; // `wait $!` allows for the `trap` t
409409
...getLabels(labels),
410410
...containerEnv,
411411
...containerUserArgs,
412-
...getPodmanArgs(params),
412+
...getPodmanArgs(params, config),
413413
...(config.runArgs || []),
414414
...(await extraRunArgs(common, params, config) || []),
415415
...featureArgs,
@@ -434,9 +434,14 @@ while sleep 1 & wait $!; do :; done`, '-']; // `wait $!` allows for the `trap` t
434434
common.output.stop(text, start);
435435
}
436436

437-
function getPodmanArgs(params: DockerResolverParameters): string[] {
437+
function getPodmanArgs(params: DockerResolverParameters, config: DevContainerFromDockerfileConfig | DevContainerFromImageConfig): string[] {
438438
if (params.isPodman && params.common.cliHost.platform === 'linux') {
439-
return ['--security-opt', 'label=disable', '--userns=keep-id'];
439+
const args = ['--security-opt', 'label=disable'];
440+
const hasIdMapping = (config.runArgs || []).some(arg => /--[ug]idmap(=|$)/.test(arg));
441+
if (!hasIdMapping) {
442+
args.push('--userns=keep-id');
443+
}
444+
return args;
440445
}
441446
return [];
442447
}

0 commit comments

Comments
 (0)