Skip to content

Allow per-disk ID map #2951

Description

@intelfx

Is there an existing issue for this?

  • There is no existing issue for this feature

What are you currently unable to do

I would like to mount host paths into Incus-launched containers while being able to control the UID:GID these paths appear as within the container.

For instance, I might want to mount a configuration file owned by the current user, but in such a way that the container would think it is owned by root (or a pre-determined daemon user).

Currently, it is only possible to make the path appear either under the same UID:GID values as on the host (shift=true) or under the nobody user (shift=false).

What do you think would need to be added

It would be nice to have a more fine-grained way to control idmapping of host mounts (what is currently achieved via the shift=<bool> disk device option).

In the simplest case, I propose a shift-to=<UID>[:<GID>] option that would translate the IDs in such a way that the mounted entry appears as owned by : inside the container.

Current behavior

$ stat /path/to/file
  File: /path/to/file
<...>
Access: (0644/-rw-r--r--)  Uid: ( 1000/ intelfx)   Gid: ( 1000/ intelfx)
<...>

$ incus config device add MYCONTAINER MYFILE disk source=/path/to/file path=/file shift=true
Device MYFILE added to MYCONTAINER

$ incus exec arch -- stat /file
  File: /file
<...>
Access: (0644/-rw-r--r--)  Uid: ( 1000/ UNKNOWN)   Gid: ( 1000/ UNKNOWN)
<...>

Suggested behavior

$ stat /path/to/file
  File: /path/to/file
<...>
Access: (0644/-rw-r--r--)  Uid: ( 1000/ intelfx)   Gid: ( 1000/ intelfx)
<...>

$ incus config device add MYCONTAINER MYFILE disk source=/path/to/file path=/file shift-to=0
Device MYFILE added to MYCONTAINER

$ incus exec arch -- stat /file
  File: /file
<...>
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
<...>

Metadata

Metadata

Assignees

Labels

APIChanges to the REST APIDocumentationDocumentation needs updatingMaybeUndecided whether in scope for the project

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions