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.

  • Does docker reuse images when multiple containers run on the same host?
  • docker bind socket to outside port
  • Waiting for a Docker container to be ready
  • Dockerfile expose port for node.js image
  • Docker ps -a doesn't show a stopped mysql client running container
  • Using host env variable with docker remote API
  • 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.

  • Docker: JACK server is not running
  • “ps” command print error timestamp in container
  • Using COPY on dockerfile for apache build
  • Docker container for Swagger UI not loading
  • Docker overlay networking centos7
  • docker mysql on different port
  • 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.