Docker compose mysql : import an existing database from local machine

I have an existing config for web developpement on macos, with mysql/php/apache enabled on it with homebrew. I would like to transfert this local config to a docker container.

I achieve to make it work for apache/php/mysql but my bd is always empty on docker even if there's data on my local machine. Here's my docker-compose.yml:

version: "3"

networks:
    devsf:

services:
    mysql:
        image: mysql:5.7
        container_name: mysql_server
        restart: always
        tty: true
        ports:
            - "4306:3306"
        volumes:
            - /usr/local/var/mysql:/var/lib/mysql
            # - /usr/local/var/mysql:/docker-entrypoint-initdb.d
        environment:
            # MYSQL_DATABASE: mydb
            MYSQL_USER: root
            MYSQL_PASSWORD: root
            # MYSQL_ROOT_PASSWORD: root
            SERVICE_TAGS: dev
            SERVICE_NAME: mysql
        networks:
            - devsf

    adminer:
        image: adminer
        container_name: adminer_server
        depends_on:
            - mysql
        restart: unless-stopped
        ports:
            - 8080:8080
        networks:
            - devsf

    apachephp:
        build:
            context: . # from php:7-apache image and contains config for apache
            dockerfile: Dockerfile
        container_name: apachephp_server
        ports:
            - "8000:80"
        volumes:
            - ./portail:/var/www/portail
        networks:
            - devsf

Then I run :

docker-compose build && docker-compose up

I don't have any error, I can authenticate myself in Adminer UI on localhost:8080 but my dbs aren't here.

When I do ls /usr/local/var/mysql I can see my folder's with .MYD and .MYI files inside my local machine.

How can I do? Thank you.

Asked By: Kev
||
The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .



# More Articles