Hello everyone!
I'm using the jupyter/base-notebook image when spawning with JHub. Thanks for the capability to change user name, uid and gid!
It seems that using usermod in the start.sh have an impact on the containers space usage.
I think this is related with a known unresolved bug of Docker with sparse file detailed here: https://github.com/moby/moby/issues/5419
Using useradd or usermod modifies logs sparse files, not well handled by docker.
There is a workaround for the useradd command, using the -l option to prevent writing the log files causing the trouble. But I can't see a similar option in the usermod command.
You will find a screenshot of multiple tries made with JHub and a DummyAuthenticator allowing me to test various UIDs. In that example I'm using the NB_USER to also set both NB_UID and NB_GID as well.

We clearly see a direct correlation.
Could anyone confirm this issue?
Thanks in advance!
Replacing the code dealing with uid and gid changes with the following code did the trick:
# Change UID:GID of NB_USER to NB_UID:NB_GID if it does not match
if [ "$NB_UID" != $(id -u $NB_USER) ] || [ "$NB_GID" != $(id -g $NB_USER) ] ; then
echo "Set user $NB_USER UID:GID to: $NB_UID:$NB_GID"
userdel $NB_USER
groupadd -g $NB_GID -o ${NB_GROUP:-${NB_USER}}
useradd --home /home/$USER -u $NB_UID -g $NB_GID -G 100 -l $NB_USER
fi
See the following screenshot:

Most helpful comment
Replacing the code dealing with uid and gid changes with the following code did the trick:
See the following screenshot:
