Search code examples
mysqldockercontainerswindows-container

How to mount Docker MySQL Data/Socket volume on Windows 10?


I'm trying to simply run the latest docker mysql image on windows 10 with a data directory from the host mounted.

I'm running

docker run --rm --name=mysql --mount type=bind,src="C:\Docker Projects\mysql\mysql_data",dst=/var/lib/mysql mysql/mysql-server  

But it's complaining about a socket not being present.

2020-01-20T17:23:22.758269Z 0 [ERROR] [MY-010270] [Server] Can't start server : Bind on unix socket: Operation not permitted
2020-01-20T17:23:22.758416Z 0 [ERROR] [MY-010258] [Server] Do you already have another mysqld server running on socket: /var/lib/mysql/mysql.sock ?

I can see a mysql mysql.sock.lock is created. I've also tried creating a mysql.sock file from the host.

I think this is telling me I need to specify where the socket file is for windows https://dev.mysql.com/doc/refman/5.7/en/deploy-mysql-nonlinux-docker.html but I can't seem to get the command syntax right?


Solution

  • You are correct. The problem is that the mysql.sock file got put into /var/lib/mysql, which is mounted into a Windows host system directory that does not support Unix domain sockets.

    Just use switch --socket=/tmp/mysql.sock when starting the server.