Docker build reset file ownership after each layer built

I’ve noticed a new strange thing where file permissions reset while building a docker image.
Consider the following Dockerfile :

FROM ubuntu

RUN mkdir -p /home/user && \
        useradd -l -u 1000 user

RUN echo start

RUN chown -R user:user /home/user && \
        ls -lart /home

RUN echo look again && \
        ls -lart /home

Using

$ docker --version
Docker version 20.10.25, build 20.10.25-0ubuntu1~22.04.1

As you can see, I chown all /home/user to be user:user on the 3’rd RUN. and it did work, as can be seen in the output of ls.
But when looking again in the 4’th RUN, I see these ownership got reset back to root.
This is new to me. I don’t know when/why it started happening.
Please help.

Here’s the output of the build:

$ docker build . -t delme
Sending build context to Docker daemon  2.048kB
Step 1/5 : FROM ubuntu
 ---> a8780b506fa4
Step 2/5 : RUN mkdir -p /home/user &&   useradd -l -u 1000 user
 ---> Running in 3c5322e6da14
Removing intermediate container 3c5322e6da14
 ---> b8cd6cff6cf1
Step 3/5 : RUN echo start
 ---> Running in 84b28e26fe62
start
Removing intermediate container 84b28e26fe62
 ---> 0132b4cea87f
Step 4/5 : RUN chown -R user:user /home/user &&     ls -lart /home
 ---> Running in 026d38b02676
total 16
drwxr-xr-x 1 user user 4096 Aug 21 22:31 user
drwxr-xr-x 1 root root 4096 Aug 21 22:31 .
drwxr-xr-x 1 root root 4096 Aug 21 22:31 ..
Removing intermediate container 026d38b02676
 ---> ab43ecd201c5
Step 5/5 : RUN echo look again &&   ls -lart /home
 ---> Running in 20a2618e9df5
look again
total 12
drwxr-xr-x 1 root root 4096 Aug 21 22:31 user
drwxr-xr-x 1 root root 4096 Aug 21 22:31 .
drwxr-xr-x 1 root root 4096 Aug 21 22:31 ..
Removing intermediate container 20a2618e9df5
 ---> 69affbc1656b
Successfully built 69affbc1656b
Successfully tagged delme:latest

I’ve downgraded to older docker.io package:

sudo apt install docker.io=20.10.21-0ubuntu1~22.04.3

Now it works. I think something is wrong with the new version. Please ignore the fact that it pulls the ubuntu package.

$ docker build . -t delme
Sending build context to Docker daemon  2.048kB
Step 1/5 : FROM ubuntu
latest: Pulling from library/ubuntu
b237fe92c417: Pull complete 
Digest: sha256:ec050c32e4a6085b423d36ecd025c0d3ff00c38ab93a3d71a460ff1c44fa6d77
Status: Downloaded newer image for ubuntu:latest
 ---> 01f29b872827
Step 2/5 : RUN mkdir -p /home/user &&   useradd -l -u 1000 user
 ---> Running in b40942bbcec8
Removing intermediate container b40942bbcec8
 ---> 0070af6f64e4
Step 3/5 : RUN echo start
 ---> Running in 8c60a7f12b60
start
Removing intermediate container 8c60a7f12b60
 ---> 483f5c6a1e4c
Step 4/5 : RUN chown -R user:user /home/user &&     ls -lart /home
 ---> Running in 7c529b3450d3
total 16
drwxr-xr-x 1 user user 4096 Aug 22 07:30 user
drwxr-xr-x 1 root root 4096 Aug 22 07:30 .
drwxr-xr-x 1 root root 4096 Aug 22 07:30 ..
Removing intermediate container 7c529b3450d3
 ---> 3763ff4101a1
Step 5/5 : RUN echo look again &&   ls -lart /home
 ---> Running in 9c12c1d3143f
look again
total 12
drwxr-xr-x 1 user user 4096 Aug 22 07:30 user
drwxr-xr-x 1 root root 4096 Aug 22 07:30 .
drwxr-xr-x 1 root root 4096 Aug 22 07:30 ..
Removing intermediate container 9c12c1d3143f
 ---> f9c1f61b0596
Successfully built f9c1f61b0596
Successfully tagged delme:latest