grabbag
grabbag

Reputation: 1030

can't find the mysql database in docker-compose

I specify a volume for myself in the docker-compose.yaml but nothing appears in this directory. I can connect to the db from mysql workbench and via nodejs npm package "mysql": "^2.15.0".

I can stop the docker containers and restart them and the db is persisted. If I restart my PC, the db disappears and it needs to be recreated.

Q: What is the correct way to specify a location for the mysql db in a docker-compose.yaml file so the db is persisted?

My environment is a windows pc running docker Version 18.03.0-ce-win59 (16762).

My docker-compose.yaml is as follows:

mysql-purple:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: 123456
      MYSQL_DATABASE: purple
    ports:
      - "3308:3306" # externaly use 3308 example mysql workbench localhost: 3308)
    volumes:
      - "C:/Users/john_/Documents/mySQLdatabases:/var/lib/mysql:rw"

Upvotes: 0

Views: 956

Answers (1)

yamenk
yamenk

Reputation: 51758

This is a known issue with docker on windows, check Volumes from docker-compose file no longer working after a reboot

Upvotes: 1

Related Questions