# Docker-rootless high UIDs issues

**URL:** <https://forums.docker.com/t/docker-rootless-high-uids-issues/99188>\
**Category:** General\
**Created:** [September 30, 2020, 8:25pm UTC](https://forums.docker.com/t/docker-rootless-high-uids-issues/99188 "2020-09-30T20:25:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aacebedo](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@aacebedo](https://forums.docker.com/u/aacebedo)\
**Post date:** [September 30, 2020, 8:25pm UTC](https://forums.docker.com/t/docker-rootless-high-uids-issues/99188/1 "2020-09-30T20:25:11Z")

</div>

Hi there,

I am currently evaluating using docker-rootless on a 19.03 installation and I am facing several questions and issues on how it works. On my system I have multiple users with high uids (\> 1000000000) and I want to offer them docker-rootless acess.

In the documentation [https://docs-stage.docker.com/engine/security/userns-remap/](https://docs-stage.docker.com/engine/security/userns-remap/) it is said that the uid mapping shall map the root user (uid 0) on the first value of a range I set.

However in rootless mode when my root user creates a file, the owner on the host is not the first value of the subuid range but the uid of the user who started the daemon.

For instance I have created a user named “foo” with uid 2000000 and put the following in /etc/subuid  
`foo:1000:1000`  
Then I started a new container and shared a folder of the host:  
`docker run --rm -ti --name test -v /tmp/test:/mnt/local centos:8 bash`

When executing “touch /mnt/local/test1” as root in the container, the file appears to be owned by “foo” (uid 2000000) on the host.

My second issue is about copying files with docker cp.  
If I create a file on the host `/tmp/test1` owned by “foo” and execute `docker cp /tmp/test1 test:/mnt/local/test1` as “foo” , the operation fails with a lchown invalid argument. This seems to be triggered by the fact that docker is trying to map the owner of the file (2000000) into the range 1000:1000 and fails as there’s not enough uids available. Changing the range in /etc/subuid to:  
`foo:2000001:2000000`  
makes it work.  
The problem is that on my system I cannot change the high UID of users and I have got multiple users. So it is impossible to obtain a mapping with no overlap for all of them and to use docker cp.  
Not that pulling images containing files with uid not complying with the mapping also leads to a failure for the same reasons.

Does anyone have any idea about how to solve that ?

---

<div class="post-metadata">

**Author:** ![nestybox](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/nestybox/32/25044_2.png) [@nestybox](https://forums.docker.com/u/nestybox)\
**Post date:** [October 9, 2020, 9:08pm UTC](https://forums.docker.com/t/docker-rootless-high-uids-issues/99188/2 "2020-10-09T21:08:37Z")

</div>

Here are some thoughts that may help.

First: when you say “docker-rootless”, I assume you mean configuring Docker with [userns-remap](https://docs-stage.docker.com/engine/security/userns-remap/), rather than [rootless docker](https://docs.docker.com/engine/security/rootless/) (they are not the same thing).

Assuming this is about Docker in userns-remap mode:

For problem 1:

The `/etc/subuid` file should have the range of **subuids** associated with user foo. Those subuids are typically in a range that does not overlap with the uids of actual users on the host (e.g., `foo:231072:65536`). Thus, the `/etc/subuid` with `foo:1000:1000` that you showed does not look right since uid 1000 is likely an actual user on your system.

If you were to program the `/etc/subuid` file with `foo:231072:65536`, and then add `"userns-remap": "foo"` to the `/etc/docker/daemon.json`, then when you launch a container you’ll see that the root user (uid 0) in the container would map to uid 231072 on the host. And uid 1 would map to 231073, and so on, until you exhaust the range of 65536 subuids.

For problem 2: I suspect it’s related to the bad setup that led to problem 1.

Finally: you may want to look into [Sysbox](https://github.com/nestybox/sysbox). It’s a new type of runc that works under Docker and sets up containers to use the Linux user-namespace automatically. So

`docker run --runtime=sysbox-runc --rm -ti centos:8 bash`

would give you a container isolated with the user-namespace (and one in which you can run apps or even system software such as systemd, docker, and even k8s inside if you wanted to).
