I can't change ownership of newly created directory inside of docker container. It is not a volume and chown
runs correctly for all my colleagues - the only difference is I'm running docker on linux while they are working on macs and windows (what should not matter, right?). My docker version: Docker version 20.10.25, build 20.10.25-0ubuntu1~22.04.1
I have simplified my use case to this most basic Dockerfile (php version doesn't matter, tried with 8.0 as well):
FROM php:7.1.33-fpm AS base
RUN mkdir /home/www-data
RUN ls -ld /home/*
RUN usermod -d /home/www-data www-data
RUN ls -ld /home/*
RUN chown -R www-data /home/www-data
RUN ls -ld /home/*
RUN chmod -R 0777 /home/www-data
RUN ls -ld /home/*
I run it with docker build . --no-cache
, so there is no docker-compose used, anything cached etc.
My partial output:
Step 5/9 : RUN ls -ld /home/*
---> Running in faee10891512
drwxr-xr-x 2 root root 4096 Aug 17 08:46 /home/www-data
Removing intermediate container faee10891512
---> bd417136c193
Step 6/9 : RUN chown -R www-data /home/www-data
---> Running in 7656908de5e0
Removing intermediate container 7656908de5e0
---> e25a42b7f73b
Step 7/9 : RUN ls -ld /home/*
---> Running in e916fca31c51
drwxr-xr-x 1 root root 4096 Aug 17 08:46 /home/www-data
Removing intermediate container e916fca31c51
---> be3154bf3ad6
Expected output (just taken from docker run on windows):
#8 [5/9] RUN ls -ld /home/*
#8 sha256:ab73f23a9843a55ca731c83532c9f1b95e738525c2a8437f58ed7c17d0cf245e
#8 0.457 drwxr-xr-x 2 root root 4096 Aug 17 08:40 /home/www-data
#8 DONE 0.5s
#9 [6/9] RUN chown -R www-data /home/www-data
#9 sha256:686bd64c892edc235610feb148f1a9213bdf9238e62e74f1ca87da416c97eb99
#9 DONE 0.5s
#10 [7/9] RUN ls -ld /home/*
#10 sha256:e37fbdcf3bd0ae93dd19f8bc4b81d3c22fec176a3ef6d9b957c9c46787cb79a0
#10 0.434 drwxr-xr-x 1 www-data root 4096 Aug 17 08:40 /home/www-data
#10 DONE 0.4s
I am really puzzled about this, anyone has and idea what should I try next?