docker build Dockerfile Home Directory Ownership Lost After RUN useradd

Bug #2029893 reported by Shea Tomsin
40
This bug affects 7 people
Affects Status Importance Assigned to Milestone
docker.io-app (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

The following now fails
```
cd $(mktemp -d);

cat > Dockerfile << "END"
FROM ubuntu:22.04

ARG user=ubuntu
RUN useradd -U -m $user && [ "$(stat --format '%U' /home/$user)" = "$user" ]
RUN ls -al /home

USER ubuntu
WORKDIR /home/ubuntu
RUN stat "$(realpath .)"; [ "$(stat --format '%U' .)" = "$user" ]
END

docker build --force-rm .
```
Doesn't work with
Docker version 20.10.25, build 20.10.25-0ubuntu1~22.04.1

Does work with
Docker version 20.10.21, build 20.10.21-0ubuntu1~22.04.3

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: docker.io 20.10.25-0ubuntu1~22.04.1
ProcVersionSignature: Ubuntu 5.19.0-50.50-generic 5.19.17
Uname: Linux 5.19.0-50-generic x86_64
ApportVersion: 2.20.11-0ubuntu82.5
Architecture: amd64
CasperMD5CheckResult: pass
CurrentDesktop: ubuntu:GNOME
Date: Fri Aug 4 01:58:26 2023
InstallationDate: Installed on 2023-07-25 (9 days ago)
InstallationMedia: Ubuntu 22.04.2 LTS "Jammy Jellyfish" - Release amd64 (20230223)
ProcEnviron:
 TERM=xterm-256color
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: docker.io-app
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Shea Tomsin (stomsin) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in docker.io-app (Ubuntu):
status: New → Confirmed
Revision history for this message
Rob King (robpking) wrote :

Confirmed this is an issue after downgrading docker.io package and running the same commands.

Revision history for this message
Shea Tomsin (stomsin) wrote :
Revision history for this message
Shea Tomsin (stomsin) wrote :

Triage by https://github.com/docker/cli/issues/4481 indicates that this issue may be specific to Ubuntu

Revision history for this message
Artem Leshchev (matshch) wrote (last edit ):

Maybe it is related to https://bugs.launchpad.net/ubuntu/+source/docker.io-app/+bug/2029523 somehow. I've tested, fix from there also fixes this bug.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.