【N予備校】Windows10でDockerToolBoxをインストールしmysqlを動かそうとしたときのエラー
```
docker run --name mojipic-mysql -v %CD%/workspace/mojipic-mysql:~/var/lib/mysql -e MYSQL_ROOT_PASSWORD=mysql -d -p 3306:3306 mysql:5.7.19 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
```
`docker: Error response from daemon: invalid mode: /var/lib/mysql.`
と表示される
■原因
Windows環境ではVolumeの指定をあまりしてはいけない、と公式ドキュメントには書かれていました。
```
Tips on shared drives, permissions, and volume mounts
-
Shared drives are only required for mounting volumes in Linux containers, not for Windows containers. For Linux containers, you need to share the drive where the Dockerfile and volume are located. If you get errors such as
file not found
orcannot start service
you may need to enable shared drives. See Volume mounting requires shared drives for Linux containers.) -
If possible, avoid volume mounts from the Windows host, and instead mount on the Linux VM, or use a data volume (named volume) or data container. There are a number of issues with using host-mounted volumes and network paths for database files. See Volume mounts from host paths use a nobrl option to override database locking.
-
Docker for Windows sets permissions to read/write/execute for users and read/execute for groups and others 0755 or u+rwx,go+rx. This is not configurable. See Permissions errors on data directories for shared volumes.
```
■対処
この
adeelahmadchが コメントしました on 8 Jan 2017
で、コンテナ側のパスを指定せずにVolumeを記述したところ起動しました。
``` 変更前.bash
docker run --name mojipic-mysql -v %CD%/workspace/mojipic-mysql:~/var/lib/mysql -e MYSQL_ROOT_PASSWORD=mysql -d -p 3306:3306 mysql:5.7.19 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
```
``` 変更後.bash
docker run --name mojipic-mysql -v %CD%/workspace/mojipic-mysql -e MYSQL_ROOT_PASSWORD=mysql -d -p 3306:3306 mysql:5.7.19 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
```
これで起動が可能でした。