我正在尝试UID
1340816314
在Alpine Linux Docker容器内创建一个新用户,以便让UID
用户在主机上匹配特定用户.
问题是,adduser: number 1340816314 is not in 0..256000 range
即使我通过跟随adduser手册页重新定义UID_MAX
内部的值,我也面临着.我不认为它有任何影响,因为Alpine中的命令来自BusyBox./etc/login.defs
adduser
这是我尝试做的日志:
$ 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
您知道如何UID
在Docker容器中添加具有大型Alpine Linux 的用户吗?
这是一个工作但很脏的解决方法,通过手动创建用户,使用$UID_TO_SET
包含UID
要设置的高的bash变量:
# 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