I’ve got a docker-compose file with about 4 related services. They currently all use directories bound to the host.
I’m looking at creating a shared data volume, shared between 3 services.
Creating the volume in the docker-compose file I’m happy with. But given that 3 services are going to be sharing this volume, I don’t want a flat structure in the data volume…and the 3 services don’t create the folder upon creation.
The structure I’m after is:
\data \service2 \service3
Service1 container will use data\service2 and data\service3 directories.
Service2 Container will use data\service2 only
Service3 Container will use data\service3 3 only
Now I know I could just manually create the data volume and create the dirs by hand. But I want to learn if file this possible in compose.
Would I create another service with my own dockerfile (the others are community created), that runs on first instance and creates the data structure? If so, how can I tell this new service to only run if the data volume doesn’t exist?