HI all,
I am deploying an app to BalenaOS which operates in an NGINX container with PHP linked through a docker compose file. Both NGINX and PHP require reading the same files in order to operate. So there are some options:
- The best practice approach, create a docker volume that both containers can view, problem solved. But as it is a volume the data gets left behind on the host, so that when I deploy an app update, any deleted content from the new app will still be present on the device, sitting in the volume.
- Don’t link PHP and NGINX containers, and then have a copy of the same data in both. But involves more space being take, and more bandwidth to retrieve the images.
- Some sort of data container, that empties the existing volume, then moves the new data to that volume. Is a little messy, and also entails having the data duplicated, taking up twice the space. A mv might reduce the space issue, but this is a really messy solution.
- Rename the volumes on each app update, and enable the balena feature that disposes of unlinked volumes. But again carries risks, the disabling the disposal of unliked volumes feature was presumably disabled by default for a reason.
- Create a docker file that installs PHP and NGINX in one container. Generally bad docker practice.
- The approach used before in Docker (at least compose v2 before it was removed in v3), is to use the volumes_from feature. It means the volume can be created in the DockerFile, which by design is removed when the built container is removed. Then the docker compose file mounts the created temporary volume by using volumes_from which doesn’t require a name to be specified, or the volumes to be defined in the compose file.
I see the volumes_from feature is currently not available in Balena (https://www.balena.io/docs/reference/supervisor/docker-compose/). I would like to add a +1 request for this feature, but also to ask if anyone has found a way around this in the meantime. In short, if anyone has found a way to share non-persistent content between containers.