environment:docker for windows 10
version: Docker version 17.09.0-ce, build afdb6d4
docker images: mysql/mysql-server latest
docker had setting shared Drive C:
I want to run a mysql container, so I use follow command:
C:\WINDOWS\system32>docker run -d -p 3306:3306 -v "C:/Program Files/MySQL/Config":/etc/mysql/ -v "C:/Program Files/MySQL/Data/":/var/lib/mysql/ --name mysqlserver mysql/mysql-server
c2b45a6668746f0aa708b17f05a720ee6b4cff477eeaef714685293d1b60f44b
C:\WINDOWS\system32>docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c2b45a666874 mysql/mysql-server "/entrypoint.sh my..." 9 seconds ago Exited (1) 7 seconds ago mysqlserver
2de1dbd9880b redis "docker-entrypoint..." 4 days ago Exited (0) 4 days ago myredis
35c805969295 redis "docker-entrypoint..." 9 days ago Exited (0) 9 days ago redisServer
C:\WINDOWS\system32>docker logs mysqlserver
[Entrypoint] MySQL Docker Image 5.7.21-1.1.3
[Entrypoint] No password option specified for new database.
[Entrypoint] A random onetime password will be generated.
chown: changing ownership of '/var/lib/mysql/': Permission denied
C:\WINDOWS\system32>
I'm tired,what should I do?
Try rw
tag while specifying the volume mounts. In your case that would be
docker run -d -p 3306:3306 -v "C:/ProgramFiles/MySQL/Config":/etc/mysql/:rw -v "C:/ProgramFiles/MySQL/Data/":/var/lib/mysql/:rw --name mysqlserver mysql/mysql-server
Looks like the file C:/Program Files/MySQL/Data/
on the host mounted as a volume in the container at /var/lib/mysql/
does not have write permission set.
You can give write permission (rw
) when you mount /var/lib/mysql/
by doing
-v "C:/Program Files/MySQL/Data/":/var/lib/mysql/:rw
instead of
-v "C:/Program Files/MySQL/Data/":/var/lib/mysql/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With