2

I've a project with a large database (more or less 50GB) and since i have to run also other projects with docker/ddev this could be a problem, i for sure can make the size of the docker disk but i wanted to know if it's possible for a certain project keep the database outside docker...
With plain docker (docker-compose) projects i keep a "data" folder that's not inside docker, i would like to do more or less the same thing with ddev if it's possible.
Now i'm on OSX, but if it's possible also in Win10 it would be great.
Thanks!

rfay
  • 9,963
  • 1
  • 47
  • 89
Francesco
  • 55
  • 7
  • Can you explain further why such a database size should cause any problem, especially if you also want to run other projects? – Nico Haase Jan 10 '20 at 17:21
  • It's simple actually, it can be a problem for me having the docker volume always full only for such huge databases, or multisite websites (with like 16 or so subsites) databases... i find it much more simple to have the databases outside of the docker volume just to avoid to bring high and high everytime the setting for the storage space of docker. – Francesco Jan 12 '20 at 18:07

2 Answers2

3

ddev used to mount the database onto the host with a bind-mount, but docker has quite a number of problems with that, especially on Windows. It worked OK on mac and Linux though, didn't work well on Docker Toolbox on Win10 Home. Docker volumes are more reliable for interacting, and faster, because they're on a linux volume.

However, you could make a .ddev/docker-compose.bindmountdb.yamlwith contents like this, which basically switches back to the old approach, and bind-mounts the database into the project's .ddev/db directory.

version: "3.6"

services:
  db:
    volumes:
    - type: "bind"
      source: "./db"
      target: "/var/lib/mysql"

rfay
  • 9,963
  • 1
  • 47
  • 89
  • Awesome!! Both of the answers are great, but this is exactly what i was searching for, and moreover with the addition of a snapshot i managed to migrate a project from a pc with "normal" db in volume to another machine with a configuration for bind-mount db! Thanks! – Francesco Dec 19 '19 at 13:42
3

Another option, of course, is to run a MySQL/MariaDB server on your host computer, for that huge database. Your project could then access the database on the host using the hostname "host.docker.internal". This gets you into the business of running and managing your own database server on the host, but with a huge database it might be appropriate. You could also run the db server elsewhere on your local network, which is the same basic idea; the db server just has to be accessible from inside the web container. In either of these cases, you could use omit_containers: [db] and just not use the db container at all.

rfay
  • 9,963
  • 1
  • 47
  • 89