phphtmlapachedocker

Website hosted in docker container is not updating live


I am developping a website which I want to host inside a php-apache docker container.
I use the following command to run the container:

docker run -dit --restart unless-stopped --name my_www -p 8080:80 -v /path/to/repo:/var/www/html/ php:7.4-apache

Since I bind the repository containing the code as a volume to the container, I expect the website to "update live" when I change the code locally. I had this right behaviour last time I tried but I am now unable to get it back.
When I check the website locally at 127.0.0.1 everything is ok and changes are taken into account normaly, but they do not propagate into the docker container... For some reason, the files in the docker are stuck to an old version of the code, an old "stat" of the repository...
Any ideas how I can manage to fix this and preview changes live ?


Solution

  • Credits to @Don't Panic for helping to debug.
    The browser was caching everything so I couldn't see changes live.
    The solution was to enable the "expires" apache module inside the docker container:

    $ docker exec -it <container_id> bash
    root@<container_id>:# a2enmod expires
    root@<container_id>:# exit
    $ docker restart my_www
    

    Et voilĂ  :)