I'd like to map user postgres or root inside container to user myuser on the host. There's a lot of references to this online, but it is not very clear to me how to achieve the following:
Is there a simple way to map arbitrary user inside container to user in host by a simple command line flag at the docker-run level
Map root user inside container to myuser on host
docker run --user-remap "mysuser:root" -p 6379:6379 redis:alpine
and
Map postgres inside container to myuser on host
docker run -it -p 5431:5432 --user-remap "myuser:postgres" --rm -v /home/myuser/data:/var/lib/postgresql/data postgres:9.6.0
I do not want to apply the same settings to all my containers. So doing this at the docker daemon level by applying
sudo docker daemon --userns-remap myuser
and updating /etc/passwd, /etc/group, /etc/subuid, /etc/subgid would not help solve my problem. Is there a way to solve this problem at the docker run
stage, so that these settings can be applied on a container by container basis.
Thanks