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.

  • Following the Get Started: Stack server stuck loading page endlessly
  • Docker Machine vs Docker run
  • Docker container not starting (docker start)
  • How to configure xvfb default installation on Jenkins startup?
  • security-opt with docker-api gem
  • Docker images -a showing several images with repository <none>
  • 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.

  • MS Edge running in guest machine does not store cookies from site hosted in another guest
  • Bind-mount a host directory into a volume of a running docker container
  • How to make redis BROKER_URL dynamic on deployment to AWS instance
  • Docker, Supervisord and logging - how to consolidate logs in docker logs?
  • How to create named and latest tag in Docker?
  • is docker0 a bridge(l2) or a router(or a l3 bridge)?
  • 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.