I’ve containerized a mail server with Docker and mounted the volumes which contains MySQL database, home path for the mail storage and log files. It works with any of the container of same image when attached with preexisting data volumes.
However, there’s a restriction that volumes should be attached to only one container at a time otherwise, It will throw an error like can’t connect to database.
I’ve created a Docker compose YAML file and stacked it for load balancing as well as scaling purposes which will replicate my image instances twice as mentioned in the file and will respawn when container get destroyed. Replicas of containers are running but like the native one without the volumes data taking in from the file.
YAML file is below.