Skip to content

Idmapped mounts #4464

@saolof

Description

@saolof

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

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions