Docker: split mysql databases into different data volume containers?

I have the following Docker containers:

The web container is linked to the db container. All standard stuff.

  • Why so many layers on base images? Docker
  • Docker push to AWS ECR fails on Windows: no basic auth credentials
  • Jenkins deployment to docker swarm by using Ansible
  • AWS EB Deploy shows missing after deploying
  • SSHFS Mount for Docker Container / Node Server needs to access files on an external server
  • Deploying docker container using marathon
  • For data persistence, I want to take the data volume container approach.

    I want to be able to run several websites using these 2 containers as the main application containers (well, technically, the web container runs the main user-facing application and the db sits behind that).

    Let’s say I have siteA, siteB, and siteC using databases A, B, and C respectively in mysql.

    I would like to be able to partition these site’s database data into 3 different data volume containers (dataA, dataB, dataC) for portability, and bring them together in a single deployment (one host running web, db, dataA, dataB, dataC all linked appropriately) when needed.

    Is there a way to partition the separate mysql databases into their own data volume containers for portability? AFAIK, mysql stores all of it’s database data in /var/lib/mysql in some fashion that is not transparent in terms of the databases that mysql is storing.

    For example, it would be nice if the different databases being stored in mysql were mapped to known directories – in this case, /var/lib/mysql/A, /var/lib/mysql/B, and /var/lib/mysql/C. This way, all I would have to do persist those directories and mount them in the db container. I don’t think this is the case though.

  • Access filesystem from Node app in Docker
  • Shared Docker devicemapper lvm thinpool in a multiboot setup
  • How to set up docker elasticsearch with node?
  • docker-machine and docker for mac volumes
  • Do you need License for OS (Windows) inside Docker
  • Django show “It worked” page instead of my project when I start it docker
  • One Solution collect form web for “Docker: split mysql databases into different data volume containers?”

    Why not just run multiple instances of the db container? Mapping the dir’s as needed.

    docker run -d -v /var/lib/mysql/A:/var/lib/mysql --name dbA my_docker/my_awesome_mysql
    docker run -d -v /var/lib/mysql/B:/var/lib/mysql --name dbB my_docker/my_awesome_mysql
    docker run -d -v /var/lib/mysql/C:/var/lib/mysql --name dbC my_docker/my_awesome_mysql

    This would help if you ever needed to move dbA only to another host.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.