DEV Community

taragurung
taragurung

Posted on

docker swarm mysql service, when scaled not working

I simply created one swarm node (master). Wrote a docker-compose with multiple service one of them is mysql. Now, when I scale mysql container I get connection issue. The mysql has a volume defines as

volumes:
  - ./mysql:/var/lib/mysql

Top comments (1)

Collapse
 
bluma profile image
Roman Diviš • Edited

Mysql is not a nosql db with their “easy” scaling out... You cannot run multiple instances on one data folder, this wound’t work - locking, caching and data consistency cannot be maintaned that way. Mysql uses classic master/slave replication process and it is not that simple. You need to explicitly configure this and then writes to master are automatically mirrored to slaves. There are currently more modes of replications. Use google and look for terms like mysql replication