I'm trying to create a new user with UID
1340816314
inside an Alpine Linux Docker container in order to have a user with an UID
matching a specific user on the host.
The problem is that I'm facing adduser: number 1340816314 is not in 0..256000 range
even if I redefine the value of UID_MAX
inside /etc/login.defs
by following adduser man page. I don't think by the way that it has any impact as the adduser
command in Alpine is from BusyBox.
Here is the log of what I try to do:
$ docker run -it --rm alpine:3.4 sh
/ # adduser -D -g '' -u 1340816314 user
adduser: number 1340816314 is not in 0..256000 range
/ # echo "UID_MAX 1340816314" > /etc/login.defs
/ # adduser -D -g '' -u 1340816314 user
adduser: number 1340816314 is not in 0..256000 range
/ # echo "UID_MAX 1340816315" > /etc/login.defs
/ # adduser -D -g '' -u 1340816314 user
adduser: number 1340816314 is not in 0..256000 range
Do you know how to add a user with a large UID
in Alpine Linux inside a Docker container?
Here is a working but dirty workaround, by manually creating the user, using $UID_TO_SET
as the bash variable containing the high UID
to set:
# Create user
echo "user:x:$UID_TO_SET:$UID_TO_SET::/home/user:" >> /etc/passwd
## thanks for http://stackoverflow.com/a/1094354/535203 to compute the creation date
echo "user:!:$(($(date +%s) / 60 / 60 / 24)):0:99999:7:::" >> /etc/shadow
echo "user:x:$UID_TO_SET:" >> /etc/group
mkdir /home/user && chown user: /home/user