Docker MySQL does not popoulate database with data

I have following docker-compose.yml

version: '2'
    services:
      storage:
        image: library/mysql:5.5
        environment:
         - MYSQL_ROOT_PASSWORD=root
         - MYSQL_DATABASE=storage
        ports:
         - 3306:3306
        volumes:
         - ./mysql-initdb:/docker-entrypoint-initdb.d
         - ./mysql-volume:/var/lib/mysql

Inside docker-entrypoint-initdb.d directory following .sql script:

  • CoreOS Fleet, link redundant Docker container
  • Cannot install docker pkg dependency in Go
  • How to modify a config file of tomcat docker container using ansible?
  • Permission denied when running a container (docker 1.12.5)
  • Why use AUFS as the default Docker storage backend instead of devicemapper?
  • Docker image for windows components
  • BEGIN;
    DROP DATABASE IF EXISTS `storage`;
    CREATE DATABASE `storage`;
    USE `storage`;
    
    DROP TABLE IF EXISTS SETTINGS;
    CREATE TABLE SETTINGS (
      `NAME` VARCHAR(100) NOT NULL,
      `VALUE` VARCHAR(100) NOT NULL,
      PRIMARY KEY(`NAME`)
    ) ENGINE=MEMORY DEFAULT CHARSET=utf8;
    
    INSERT INTO
    `storage`.`SETTINGS` (`NAME`, `VALUE`)
    VALUES
    ('AAAAA','BBBBB');
    
    COMMIT;
    

    When I executes docker-compose up I get information that .sql script is executed:


    /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/1_storage_schema.sql

    When I connect to that database from MySQL Workbench I see only empty tables without data. It looks like INSERT statement was not executed.

    I tried also:

    1. Naming columns with and without “`” character
    2. Using and not BEGIN/COMMIT

  • Docker container run error: Container exited on error: exited with status 1
  • Error when creating a Docker container with MongoDB in it
  • “Installing Docker: FAILED” Error on setup with Meteor-Up and Debian 7 wheezy
  • sbt-native-packager for Docker on Mac OS X
  • Node App Can't Read File System in Docker Image
  • Can Google Kubernetes run Apache Mesos frameworks on top of it?
  • One Solution collect form web for “Docker MySQL does not popoulate database with data”

    In the volumes you are missing a /, the correct syntax will be:

    volumes:
      - ./mysql/docker-entrypoint-initdb.d/:/docker-entrypoint-initdb.d
    

    What is happening is, the content inside the folder is not getting copied, instead a folder is made inside the docker-entrypoint-initdb.d. To ensure it is present in correct place, look inside the container by using docker exec.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.