Due to issue registered on docker repository on github
"unexpected file permission error in container", #783
it is impossible to run rm -rf /somefolder
for a folder that was created with ADD
or COPY
instructions of Dockerfile.
As a workaround to this it is possible to remove individual files one-by-one in case when this operation runs on the same layer:
find /src -type f | xargs -L1 rm -f
.
Here is an example of Dockerfile
:
FROM mono
ADD . /src
# RUN cd /src &&
# chmod +x ./build.sh &&
# ./build.sh &&
# mkdir /app &&
# cp /src/build/app/* /app &&
# rm -rf /src
RUN cd /src &&
chmod +x ./build.sh &&
./build.sh &&
mkdir /app &&
cp /src/build/app/* /app &&
find /src -type f | xargs -L1 rm -f
WORKDIR /app
CMD [ "mono", "Service.exe" ]
This will leave the folder in place but there will be an option to flatten your docker image.
Thank you!