2

I am trying to use podman to create a development container to compile a project (that requires a specific distro configuration).

Using docker, the files created on the mounted volume have root:root permissions which is annoying to work with.

I'd like to find a way to get files manupulated by the container to be accessible outside the container as if they were created by the host user.

I looked at podman because I know it allows for rootless containers and I don't have a complex use case - though docker is fine too.

I have tried this:

$ whoami
> dalsh
$ id -u
> 1000
$ podman run -v $PWD:/pwd --user 1000:1000 -it ubuntu:24.04 /bin/bash
# whoami
> root
# id -u
> 1000
# cd pwd && touch foo
> touch: cannot touch 'foo': Permission denied

I have tried variations to the start up command without success

$ podman run -v $PWD:/pwd --user 1000 -it ubuntu:24.04 /bin/bash
$ podman run -v $PWD:/pwd --userns keep-id -it ubuntu:24.04 /bin/bash
$ podman run -v $PWD:/pwd --user dalsh -it ubuntu:24.04 /bin/bash

Any idea how to run a container with either docker or podman that inherits the permissions of the user starting the container and gives the same access permissions to the mounted volume?

1 Answers1

0

Looks like I found a solution shortly after asking this, I had to use the :Z flag on the volume mount

$ podman run -v $PWD:/pwd:Z -it ubuntu:24.04 /bin/bash