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:

  • Docker / how to determine link?
  • Docker doesn't start MONGODB, and IPAddress doesn't appear, when started with other services
  • Tool to automate Docker Swarm
  • Docker disk space leak
  • How do I run a docker container as a privileged user with user namespaces
  • Connecting to running docker containers from localhost
  • 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

  • High Availability for Bluemix Secure Gateway Docker Client
  • Windows Container swarm publish port and not access
  • docker: how to do/setup networking container-to-host for udp / snmp
  • Communicating between a windows and linux docker container on the same host
  • Docker error response from daemon: Conflict. already in use by container
  • Opening a port from a docker container on AWS to the rest of the world
  • 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.