Idmapped mounts

Open
#4,464 1 comment 2 reactions 1 assignee View on GitHub

Maintainers usually reply within 3 days

@Shubhranshu153 is already working on this.

Since Sep 17, 2025.

Assessment

This issue has not been assessed yet.

Description

kind/feature
What is the problem you're trying to solve

Mapping a specific uid/gid pair inside the container to a specific user outside the container. For example, mapping the postgres uid/gid inside to a specific service account outside.

Describe the solution you'd like

Podman has two examples of commands which are more granular than --userns-remap which is global.

One is --userns=keepid:uid=...,gid=... which maps the host user to a specific user inside the container, but that is a bit too tightly coupled to its fork/exec architecture.

The other that would be a good fit for nerdctl is idmapped mounts, the --volume and --mounts option allow you to define arbitrary bindings at the level of individual mounts. This is its documentation:

· idmap: true or false (default). If specified, create an idmapped mount to the target user namespace in the container.
The idmap option supports a custom mapping that can be different than the user namespace used by the container.
The mapping can be specified after the idmap option like: idmap=uids=0-1-10#10-11-10;gids=0-100-10. For each triplet, the first value is the
start of the backing file system IDs that are mapped to the second value on the host. The length of this mapping is given in the third value.
Multiple ranges are separated with #.

For the usecase of running a database container this is exactly what you want most of the time.

Additional context

No response

Dominant language
Go
Stars
10.5k
Forks
853
Avg merge
6d 14h
Merged PRs (30d)
38

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No 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 containerd/nerdctl

All issues in containerd/nerdctl

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.