Docker Community Forums

Share and learn in the Docker community.

Mysql container fails on local volume (docker on windows 10)

We have an issue where mysql fails as soon as we try to use a local volume to store persistent data (docker-compose file below). It comes up with a long list of errors:

[Warning] [MY-012579] [InnoDB] fallocate(17, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 16384) returned errno: 22

We have tried already the option: "command: “–innodb_use_native_aio=0” as this was suggested elsewhere. Without the local volume the mysql container works flawless. Would appreciate any hints.

mysql:
image: mysql/mysql-server:latest
container_name: mysql
command: “–innodb_use_native_aio=0”
ports:
- 3306:3306
volumes:
- “/C/Users/reparaturo/chatbot/mysql:/var/lib/mysql”

Use a named volume for persistent data, don’t store db data in the Windows file system. For what reason do you want these files and folders in c:?

Thank you - the named volume resolved the issue.
The reason for local and persistend storage was to find a way to backup the data - but this is another story…

That’s what I was suspecting. Don’t expect that you get a reliable backup if you copy the content of /var/lib/mysql. If your database is not too big the best way is to use mysqldump.

I had the same problem with my Windows 10 Enterprise, I couldn’t find perfect solution around it because it seems to be my Windows version issue - I have ran the same image on other windows (8 & 10 professional) successfully. My temporary work around was to remove the /var/lib/mysql mount entirely from the docker-compose file allowing the database data files to be created and modified in the container itself.

I use kitematics which will restart and reattach my created container anytime I want to work on the container, like that I don’t loose my data when the container exit. If you don’t use kitematics this what it does. After running docker-compose the image will be created and a container will be created to run it as well, I avoid using run on the created image because this will create new container I stick to running the following sequentially

docker ps -a # this command will get container_id of all container, those that are running and those that are not
docker start <container_id> # start container from background
docker attach <container_id> # attach container to standard input
With these docker commands my data were preserved in the container even after exiting and restarting

BACK UP
Now whenever I want to move the data, I will commit my container into an image and save the image to local storage

docker commit <container_id> <backup_image_name>:<1_31_2017> # I use date to tag it
docker save -o <local_storage_tar_name> <backup_image_name>
RESTORE
Whenever I need to restore the mysql container either on my computer or for a new programming intern

cd <dir_containing_the_tar_file>
docker load -o <local_storage_tar_name>
This solution is for your update

File ./ib_logfile101: ‘aio write’ returned OS error 122. Cannot continue operation
I hope this helps somebody

Thank you - I will check this out as well.