Hi all,
I am new to Docker and currently stuck trying deploy a stack with apache and mysql using persistant storage for the database.
I understand how to do this as single container (non-swarm), but how does this work if running as a swarm with replicas of mysql service?
I have been trying to get this to work by mounting a samba share as the volume for mysql in a compose file but have failed to get it working. Samba share is mounted and accessible by all nodes in the swarm to /samba-vol
Any suggestions or best practice of how to properly set this up?
This is my docker-compose.yml:
(Apologies for the formatting, all my indentation for some reason was removed from my post)
version: β3.7β
services:
mariadb:
image: mariadb:latest
networks:
- myNetwork
secrets:
- db_root_password
ports:
- β3306:3306β
deploy:
replicas: 3
update_config:
parallelism: 2
delay: 10s
restart_policy:
condition: on-failure
environment:
MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password
MYSQL_DATABASE: mydatabase
volumes:
- samba-vol:/var/lib/mysql
- samba-vol/sql-scripts:/docker-entrypoint-initdb.d
apache2:
image: apache:latest
args:
- PHP_SOCKET=php:9000
volumes:
- samba-vol/html:/var/www/html
ports:
- 80:80
- 443:443
secrets:
db_root_password:
file: ./secret
networks:
myNetwork:
volumes:
samba-vol: