A Docker Container folder structure that's flexible and scales

Docker doesn't really impose a folder structure on how you organize your containers.

You typically want to separate your Docker development environment from your Docker runtime environment even if at the start they're on the same host.

I store all my Docker container build files (Dockerfiles) as well as any supplementary scripts and config files in my docker folder off my home folder.

/home/me/docker
  /mysql
    Dockerfile
    my.cnf
    prep-volumes.sh
    mysql-setup.sh
  /mongodb
    Dockerfile
    mongodb.conf
  /redis
    Dockerfile

The benefit of this approach is that you can manage the changes to these files via your favourite source code management system, e.g. Github.

My containerized databases have their data and logging disk volumes mapped into the container. Keeping the data & log files outwith the containers gives you lots of flexibility wrt. moving DBs between containers as well as backup strategies.

My DB container data & log files are held below /var/docker on the Docker host:

/var/docker
  /mysql1
    /var
      /lib/mysql
      /log/mysql
      /run/mysqld
    /etc-mysql/conf.d
  /mysql2
    /var
      /lib/mysql
      /log/mysql
      /run/mysqld
    /etc-mysql/conf.d
  /mongodb1
    /data
  /mongodb2
    /data
  /mongodb3
    /data

In the example above, I've got MySQL1 and MySQL2 in a master/slave setup, and MongoDB1, MongoDB2, and MongoDB3 in a replica set, all containerized on the same host (not recommended for production ;-).

This setup works for me. I'd be interested in finding out what other people are using?