I have a Dockerfile and want to embed one function user (bob) which has same uid (7200720) on the working VM
FROM docker.io/ubuntu:focal
RUN groupadd -g 2000 robots
RUN useradd -m -g 2000 -s /bin/bash -u 7200720 bob
USER bob
In docker, it works fine
$ docker build -t bob .
$ docker run bob id
uid=7200720(bob) gid=2000(robots) groups=2000(robots)
Now I try to migrate to podman env (podman v4.1.1)
$ podman build -t bob .
..
STEP 4/5: RUN useradd -m -g 2000 -s /bin/bash -u 7200720 bob
useradd: warning: chown on `/home/bob' failed: Invalid argument
..
Successfully tagged localhost/bob:latest
84e7b608fcf45ccedeb8624a88a1692013d5d41cf93954f296ce3351042e0513
..
$ podman run bob id
Error: OCI runtime error: runc: container_linux.go:380: starting container process caused: setup user: invalid argument
Are there anyway to make it working? (I do need big uid)
First prepare some directories
Build the container image
Test the container image
Explanation of the --uidmap options
--uidmap=0:0:10000maps over all of smaller UIDs in the container image. The range size 10000 was chosen rather arbitrarily.I see noticed there are also a few users with a higher UID.
so I added an --uidmap for the UID 65534 too (
--uidmap=65534:10000:1).--uidmap=7200720:10001:1maps over the UID needed for the user bob.Reduce the size of the container image
By adding the useradd option --no-log-init, it's possible to reduce the size of the container image from 2.41 GB to 75.2 MB. (I didn't use that option in the examples above).
See also
https://github.com/containers/podman/blob/main/troubleshooting.md#6-build-hangs-when-the-dockerfile-contains-the-useradd-command