I’ve noticed that, for a base image of ubuntu at least, when I do a “RUN useradd” in my Dockerfile, that the resulting image size changes as a function of the UID specified for the user… Its not a little change either, and as the UID gets rather large, the resulting image is huge… Here’s my Docker file:
FROM ubuntu
RUN useradd -ms /usr/bin/tcsh -u 1000 -g users id1000
#RUN useradd -ms /usr/bin/tcsh -u 10000 -g users id10000
#RUN useradd -ms /usr/bin/tcsh -u 100000 -g users id100000
#RUN useradd -ms /usr/bin/tcsh -u 1000000 -g users id1000000
#RUN useradd -ms /usr/bin/tcsh -u 10000000 -g users id10000000
CMD ["/usr/bin/tcsh"]
If I build an image from the file as shown, the resulting size is 111MB…
If I comment the “RUN useradd” line with UID 1000, and uncomment the one with UID 10000000, and build an image from it, the resulting size is 3.35GB ![]()
In fact, here’s the “docker images” for each:
docker-check-id10000000 latest b74918a8447b 19 seconds ago 3.35GB
docker-check-id1000000 latest bc20674c3cf5 59 seconds ago 435MB
docker-check-id100000 latest 890b82984181 About a minute ago 143MB
docker-check-id10000 latest 872f5e42142e About a minute ago 114MB
docker-check-id1000 latest 72016a7278ba About a minute ago 111MB
Why does a different UID of an added user affect the image size so much, and is there a way around it other than just using small UIDs?