I have the following 2 Dockerfile files:
- version A
FROM php:8.4.14-fpm-alpine3.22
RUN rm -fr /var/www/html/
RUN mkdir /var/www/test
RUN mv ${PHP_INI_DIR}/php.ini-production ${PHP_INI_DIR}/php.ini
WORKDIR /var/www/test
- version B
FROM php:8.4.14-fpm-alpine3.22
RUN mkdir /var/www/test
RUN mv ${PHP_INI_DIR}/php.ini-production ${PHP_INI_DIR}/php.ini
RUN rm -fr /var/www/html/
WORKDIR /var/www/test
With version B the directory /var/www/html is actually removed, instead in version A the directory keeps coming back.
I thought it could be that in the base image the /var/www/html was defined as VOLUME, but thatâs not the case.
I thought it could be a cache layer problem but also running docker system prune and then docker image build --no-cache doesnât solve the issue.