User mapping on RedHat 7.3

Hello,

I’m running Docker 1.12.6 on RedHat 7.3. My situation is simple, here my Dockerfile :

FROM centos:7

RUN mkdir -p /usr/src/test && groupadd --gid 30005 testuser && adduser --gid 30005 --uid 30005 testuser && chmod -R 777 /usr/src/test && chown -R testuser:testuser /usr/src/test

USER testuser

The UID 30005 is the testuser’s UID on the host.
I build this image then I run the container with :

docker run --rm -v ${VOLUME_ID}:/usr/src/test -w /usr/src/test myimage sh -c "id && touch /usr/src/test test.txt && ls -la /usr/src/test"

The output is :

uid=30005(testuser) gid=30005(testuser) groups=30005(testuser)
-rw-r--r--. 1 testuser testuser   0 Oct 10 09:00 test.txt

But on the host, “ls -la” give me :

-rw-r--r--.  1  135006  135006    0 Oct 10 11:03 test.txt

Why the owner of the test file isn’t testuser ? And why the owner UID/GID of the test file isn’t 30005 ? I know there is a user mapping by Docker but I don’t understand how to configure it.

Thank you.