Hi, I am installing a mysql container and I want it to take my datas from my windows host machine.
Here is the compose file I have writed, but it doesnt recognize tha name variable:
version: "3.7"
services:
db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
volumes:
- type: volume
source: C:\ProgramData\MySQL\MySQL Server 8.0\Data\test1
target: /var/lib/mysql/
name: sqldata
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: example
volumes:
sqldata:
Ive also tried
volumes:
- C:\ProgramData\MySQL\MySQL Server 8.0\Data\test1:/var/lib/mysql/
Ive already enabled $Env:COMPOSE_CONVERT_WINDOWS_PATHS=1 to accept window’s format path but I cant make it work
Hi,
Thank you for your help I have opened some docs about bind volumes and that was exactly what I needed for.
However there is not much informations on docker windows, I’ve seen that the path of the source is written as it is on windows
C:\Users\fil1\my file2\myfile_3
but you used
/c/Users/ffil1/my file2/myfile
, which one is the correct format ? and does it allows spaces on the name ?
Yes, if you have spaces in the Windows source, you can encapsulate the value. The format I used works on Docker for Windows. The other format option works as well.
Command line (with space in src directory):
docker run -d -it --name spacetest --mount type=bind,source="/c/kurowski/matthew/mysql test",target=/var/lib/mysql/test lts:mak-mysql
or
docker run -d -it --name spacetest --mount type=bind,source="c:\kurowski\matthew\mysql test",target=/var/lib/mysql/test lts:mak-mysql