'Why MySQL in container is empty, but DockerFile has run command to create data? [duplicate]

I want create dockerFile, that will build image, that contains some data_preset, so mysql is not empty;

  1. I create some mysqlDump files and put them in base folder

  2. Make DockerFile

FROM mysql:5.7

RUN mkdir /dbsheme

COPY /base/ /dbsheme

RUN /bin/bash -c "/usr/bin/mysqld_safe --skip-grant-tables &" && \
  sleep 5 && \
  mysql -u root -e "CREATE DATABASE main" && \
  mysql -u root -e "CREATE DATABASE shard1" && \
  mysql -u root -e "CREATE DATABASE docker" && \
  mysql -u root main < /dbsheme/main.db && \
  mysql -u root shard1 < /dbsheme/shard1.db

CMD ["mysqld"]
  1. Build docker image docker build . -t my_custom

  2. Run image docker run --name mysql_with_dump -v db/docker/data:/var/lib/mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=pass -d my_custom

  3. Look inside the container and it is default mysql without my tables and dump. What did i wrong with setup?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source