I want to configure file permissions for files that I add to the docker sample. I have this simple docker file:
FROM ubuntu:utopic WORKDIR /app RUN groupadd -g 1000 baz && useradd -u 1000 -g baz baz -d /app -s /bin/false RUN chown baz:baz /app && chmod g+s /app
Building this with docker build -t abc . where is the foo file in . creates an image. However, permissions on /app/foo inside are not what I want.
docker run abc ls -la total 12 drwxr-xr-x 2 baz baz 4096 Sep 2 23:21 . drwxr-xr-x 37 root root 4096 Sep 3 07:27 .. -rw-rw-r-- 1 root root 419 Sep 2 21:43 foo
Please note that the foo file does not belong to the baz group, despite the setgid bit specified in the /app directory. I could use the RUN chown -R baz:baz /app after adding the files, but this will copy the created layer (note the size of the two layers below):
docker history abc | head -n 3 IMAGE CREATED CREATED BY SIZE COMMENT b95a3d798873 About a minute ago /bin/sh -c chown -R baz:baz /app 419 B 7e007196c116 About a minute ago /bin/sh -c
Is there any way around this and accessing the added files that I want?
source share