7

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.

JAMSHAID
  • 291

3 Answers3

3

I had a similar problem with docker.io on Ubuntu 22.04, with this simple Dockerfile,

FROM ubuntu:22.04

RUN useradd -m -u 1000 -s /bin/bash xyz && ls -l /home RUN ls -l /home

the ownership of the xyz homedir got set to root:root between the RUN commands. I found a solution in setting DOCKER_BUILDKIT=1,

$ DOCKER_BUILDKIT=1 docker build .

Maybe you can define or set that in your Azure pipeline.

0

I ran into the same problem and ended up fixing it by doing a clean re-install of Docker. I followed this guide to uninstall completely (except didn't need to delete docker group). Then followed the regular docker guide to re-install.

0

Maybe the problem is the one metioned here. The bug is fixed in docker.io version 20.10.25-0ubuntu1~20.04.2 / 20.10.25-0ubuntu1~22.04.2.

Updates:

Markus
  • 1