Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

How to map mysql data folder which is on windows 10 (host) to the mysql container which is installed in docker #53

Closed
Avimobi opened this issue Dec 18, 2017 · 7 comments

Comments

@Avimobi
Copy link

Avimobi commented Dec 18, 2017

Actually i want to use my running mysql database's data folder which is host windows 10 machine from the container which is installed inside the docker. pls help me out thanks .

@Avimobi Avimobi changed the title How to map mysql data folder which is on windows 10 to the mysql container which is installed in docker How to map mysql data folder which is on windows 10 (host) to the mysql container which is installed in docker Dec 18, 2017
@tianon
Copy link
Member

tianon commented Dec 18, 2017

I'd recommend reading through https://docs.docker.com/engine/admin/volumes/bind-mounts/ and https://rominirani.com/docker-on-windows-mounting-host-directories-d96f3f056a2c.

In the future, these sorts of questions/requests would be more appropriately posted to the Docker Community Forums, the Docker Community Slack, or Stack Overflow.

@tianon tianon closed this as completed Dec 18, 2017
@yosifkit
Copy link
Member

If you are using "docker-toolbox" with "boot2docker" then this comment would apply (and has a handy compose example): #42 (comment).

If you are using "Docker for Windows", then this comment will apply: #42 (comment). In summary, it will not work at all on certain versions of percona/mysql/mariadb if you are trying to share a volume from Windows to a container running inside the VM.

@adamdehaven
Copy link

@yosifkit Just curious, did this ever get resolved? I'm still having the same issue. I can post my docker-compose.yml file if that's helpful

@yosifkit
Copy link
Member

In some cases, it works fine to share a folder for the database files from windows to a Percona container. See the links in my last comment to see what will work. It depends on if you are using "docker-toolbox" with "boot2docker" or "Docker for Windows". (there is also a minimal compose example on the first link)

@adamdehaven
Copy link

I've tried using Docker for Windows as well as Docker Toolbox. Here's there relevant part of my yml file:

version: '3'
services:
  app:
    build:
      context: .
      dockerfile: .docker/Dockerfile
    image: my-image-name
    ports:
      - 80:80
      - 443:443
    volumes:
      - .:/srv/app
    links:
      - mariadb
    environment:
      DB_HOST: mariadb
      DB_DATABASE: docker_db
      DB_USERNAME: appuser
      DB_PASSWORD: password
  mariadb:
    image: mariadb:10.3.4
    ports:
      - 13306:3306
    environment:
      MYSQL_DATABASE: docker_db
      MYSQL_USER: appuser
      MYSQL_PASSWORD: password
      MYSQL_ROOT_PASSWORD: password
    volumes:
      - .docker/db:/var/lib/mysql

This won't create the link and store the files on the Windows machine from the VM when the database is created

@yosifkit
Copy link
Member

Well, if you are using mariadb on Docker for Windows a shared folder will probably not work since all previous versions failed (and we have no idea how to fix it):

Definitely failing (Invalid argument as described in the OP):

  • mariadb:5.5
  • mariadb:10.0
  • mariadb:10.1
  • percona:5.7

- #42 (comment)

At the time, mariadb:10.1 was the only one failing on Docker Toolbox, so I assume that newer versions would also fail.

I guess one solution is to use named volumes: #42 (comment).

@adamdehaven
Copy link

Thanks for the help -- trying to get our client to let us switch from mariadb

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants