I'm using the following command to create a user and home directory, but for some reason, the newly created home directory is owned by root:
useradd --user-group --create-home --base-dir /opt --shell /bin/bash testuser
I'm creating a Docker image based on eclipse-temurin:11.0.15_10-jre-focal (based on Ubuntu 20.04). The command above is included in my Dockerfile, and the strange thing is that when I build it locally on my Windows box, the home directory is owned by the new user, but when I build it with an Azure,, DevOps pipeline, the home directory is owned by root. I don't understand what would cause the useradd command to behave differently. I found posts with a similar issue related to the home directory being on NFS volumes, but it's not the case here: /opt is inside the container.