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:

  • Restrict Docker exposed port from only specific IP adresses
  • Unable to run docker commands after new docker installation
  • Odd behaviour of dnsmasq across docker containers
  • How to change docker installation directory in centos 7 with docker 1.13 version
  • How to use properly centos dockerfile with ubuntu host?
  • Vagrant Docker provisioner on 32 bit machines
  • 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

  • Elastic Beanstalk and Dockerfile ARG instruction
  • access docker VM in private network (docker-machine)
  • Specify location of volumes in docker
  • Connecting Logstash and Rabbitmq docker containers
  • Docker and grunt-based workflow automation
  • Docker with different kernels
  • 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.