I'm currently trying to deploy a PHP app via Docker. The stack is Caddy -> PHP-FPM, and I'm using a separate container for each component.
Due to the way those components function, both the Caddy and php-fpm containers need to see the application code. (In theory I could present only the PHP files to php-fpm and only the static files to Caddy, but this is too much of a pain.) Thus, I mount a volume with the app code, and put it on both containers.
This works fine, so long as the volume does not exist at build time. However, if the volume already exists, then the data on that volume is used, and the new version of the app doesn't get copied into it. The only way I've found to make it work is to manually docker volume rm
the volume every time I build, which is a pain, and doesn't seem like the right way to do things.
How can I automatically overwrite the existing volume contents at build time? Alternatively, how can I share the code between the two containers without a volume? Apparently tmpfs mounts can't be shared, so that's no good.