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:

  • Build context folder in a remote registry?
  • Docker Mount Volume Directory with Install Files
  • Get the external Container Id to the Go Template
  • Multiple dockers and multiple domains on elastic beanstalk
  • Using sudo inside a docker container
  • start multiple processes in docker container from Dockerfile
  • 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

  • Cannot install gems from git in dockerized rails app
  • How to make volume as optional, so if I not required mount db so disable volume using flag
  • Updating boot2docker to 1.4.0 not taking
  • Packaging an app in docker that can be configured at run time
  • Crash Loopback Error: Why do imported DockerHub pods never start in Openshift Origin?
  • Using the postgres image in a test
  • 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.