Can't write to file in "/home/*/bin/" for Docker Alpine

35 Views Asked by At

For the Dockerfile below, I get an error if I try to write to a file in "/home/*/bin/" using a command inside the image. I can use a Dockerfile COPY command to write in the bin directory, but a RUN cp ... command fails. Similarly, if I open a shell into a container based on this, I cannot write to a file in "/home/*/bin/" (the file is created empty, and writing fails).

# Yes, this is a deprecated version of Alpine, but I need to do some legacy testing
FROM alpine:3.11

RUN mkdir -p /home/test/bin

# This works
COPY Dockerfile /home/test/bin/

# This fails with the error: 0.395 /bin/sh: can't create /home/test/bin/test.txt: Permission denied
RUN echo "This is a test" > /home/test/bin/test.txt

I can work around this, but I'm curious as to WHY I cannot write to a file in the bin directory in the /home directory. I can create a bin directory elsewhere in the system and that works, so clearly there is some kind of security in effect to block /home/*/bin/*. Any hints....?

0

There are 0 best solutions below