Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Not sure you can mount volumes from host for MySQL data on Windows Docker #36

Closed
phpguru opened this issue Dec 1, 2016 · 4 comments
Closed

Comments

@phpguru
Copy link

phpguru commented Dec 1, 2016

I had been using the Percona image for awhile with the following run command:

docker run -d -e APP=db -e \ 
MYSQL_ROOT_PASSWORD=pass -e MYSQL_DATABASE=db \
-e MYSQL_USERNAME=user -e MYSQL_PASSWORD=pass --name=db \
-p 3306:3306 percona:latest

Specifically note I am not using -v option.

It works, but no data is retained in the container. I figured this is due to mapping /var/lib/mysql to an endpoint expected to come from host volume.

After some experimenting with -v option to docker run command, I find the Percona container only stays running for maybe 7 seconds. Here is the relevant portion of the logs.

Initializing database
2016-12-01T20:18:09.168809Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mod
e in a future release.
2016-12-01T20:18:09.168846Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2016-12-01T20:18:17.961137Z 0 [Warning] InnoDB: Retry attempts for writing partial data failed.
2016-12-01T20:18:17.961206Z 0 [ERROR] InnoDB: Write to file /var/lib/mysql/xb_doublewritefailed at offset 0, 1048576 bytes should have been written, only 0 were written. Operating syste
m error number 22. Check that your OS and file system support files of this size. Check also that the disk is not full or a disk quota exceeded.
2016-12-01T20:18:17.961236Z 0 [ERROR] InnoDB: Error number 22 means 'Invalid argument'
2016-12-01T20:18:17.963717Z 0 [ERROR] InnoDB: InnoDB Database creation was aborted with error Generic error. You may need to delete the ibdata1 file before trying to start up again.
2016-12-01T20:18:18.564793Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2016-12-01T20:18:18.564947Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-12-01T20:18:18.564978Z 0 [ERROR] Failed to initialize plugins.
2016-12-01T20:18:18.564998Z 0 [ERROR] Aborting

This leads me to wonder if there is any way to use the container as intended on Windows. I may need to build one in which the data can persist inside the container using docker commit.

@yosifkit
Copy link
Member

yosifkit commented Dec 1, 2016

That looks like permission issues on the bind mount and is similar to MariaDB/mariadb-docker#30, MariaDB/mariadb-docker#50, MariaDB/mariadb-docker#58, and docker-library/mysql#153; which is fixed by #21 (assuming you are using docker installed by Docker Toolbox and not "Docker for Windows").

You should be able to run the container with --user 1000:50:

$ docker run -d -e APP=db -e \ 
MYSQL_ROOT_PASSWORD=pass -e MYSQL_DATABASE=db \
-e MYSQL_USERNAME=user -e MYSQL_PASSWORD=pass --name=db \
-p 3306:3306 --user 1000:50 -v /C/Users/data-dir/:/var/lib/mysql/ percona:5.7

Side note: Docker commit respects the VOLUME and would not save anything from the directory.

@yosifkit
Copy link
Member

Closing since it seems like this was solved. Let us know if this was closed in error.

@boycce
Copy link

boycce commented May 27, 2018

Still receiving this error on Docker for windows.

@BizarroDavid
Copy link

BizarroDavid commented Aug 10, 2018

I was able to FIX this issue by deleting all unused/dangling volumes. You may need to clean up dangling images and containers too. See https://gist.github.com/bastman/5b57ddb3c11942094f8d0a97d461b430

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

No branches or pull requests

4 participants