Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around database storage problems on Docker for Windows/Mac/Docker Toolbox #714

Closed
cweagans opened this issue Mar 6, 2018 · 6 comments
Assignees
Milestone

Comments

@cweagans
Copy link
Contributor

cweagans commented Mar 6, 2018

What happened (or feature request):

MariaDB in a Debian-based container on Docker for Windows with a host-mounted volume for /var/lib/mysql fails to start (has trouble writing the data files to disk on the network mount).

MariaDB is also failing in new and fun ways with Docker Toolbox, which is the path toward supporting Windows 10 Home + older Macs.

To get around this, I propose that we do the following:

  • Stop using host mounts for /var/lib/mysql and use Docker volumes instead
  • When a database container is stopped, dump the database to a host mount (mysqldump or similar)
  • When a database container is started, if the dump file is present, import it and delete it

The last two points would be sort of optional, but very convenient. We could also not include them by default and document how to set up that behavior in the app's hooks.

This sidesteps the issue of keeping the mysql data directory on a network mount, and also allows for persisting the database contents on the host. It also allows us to not dive into mariadb's source and figure out complex problems that we don't have the time to fully understand.

What you expected to happen:

How to reproduce this:

Version: Please include the output of ddev version, docker version and the project's .ddev/config.yaml.

Anything else do we need to know:

Related source links or issues:

Please use a complexity rating of 1-5 (5 is high) for a feature request. (High complexity implies more PR planning)

@rfay
Copy link
Member

rfay commented Mar 7, 2018

This definitely has potential. Shortcoming: A docker reset destroys all databases for all projects. If things have been stopped/rm-ed then this is OK, and probably not much lost anyway.

We might be able to just use the tar-up-mysql approach since we use INNODB_FILE_PER_TABLE, and it would be much quicker than mysql import.

@rfay rfay added the hibernate label Apr 16, 2018
@rfay rfay changed the title Work around database storage problems on Docker for Windows/Docker Toolbox Work around database storage problems on Docker for Windows/Mac/Docker Toolbox May 16, 2018
@rfay
Copy link
Member

rfay commented May 16, 2018

Note that Mariadb 10.2 has this problem even on macOS. See https://jira.mariadb.org/browse/MDEV-16015, a never-ending set of problems with Mariadb. There's a good wrapup in wodby/docker4drupal#244 (comment) (solution suggested is same as here) and MariaDB/mariadb-docker#95

@rfay
Copy link
Member

rfay commented May 24, 2018

Note that the proposal here was actually implemented in #349 as a competing approach to the direct-mounting of the db. @beeradb 's comment at that time was

We've decided to go with host mounting for volumes. The most compelling reason we did this was that we're always willing to bet against docker stability, and we'd like to maintain the ability for people to reset their local docker setup if needed. We'll still persist data to the host via #337

And that betting against docker stability is a pretty reasonable thing. If we go with volumes, a docker event can destroy everything. However, @cweagans suggests in this issue a backup dump, perhaps with xtrabackup.

@dclear dclear added incubate and removed hibernate labels May 29, 2018
@rfay rfay added this to the v1.0.0 milestone Jul 11, 2018
@rfay rfay self-assigned this Jul 11, 2018
@rfay
Copy link
Member

rfay commented Jul 11, 2018

I'm taking an initial look at this to make sure I understand the territory. This may just be a short experimental phase to determine where we want to go with it.

@rfay
Copy link
Member

rfay commented Jul 11, 2018

Sadly, docker volumes don't support anything but root mount permissions, moby/moby#2259 and docker/compose#3270

There is an interesting workaround (Run a temp container first that chowns the voume, and make the real container depend on that one (which exits right after chowning).

@rfay
Copy link
Member

rfay commented Jul 11, 2018

We might be able to switch back to the start-as-root-and-sudo-to-correct-user approach, which uses an environment variable to specify the correct UID within the container.

Or why not just add sudo into the mariadb container like we do in the web container, and let the startup script sudo the perms?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants