I searched for a long time, a lot of answers, nothing helps ... There is the following docker-compose.yml
version: '2' services: nginx: build: ./docker/nginx depends_on: - php7 - db volumes: - ./app:/var/www ports: - "8080:80" php7: build: ./docker/php7 ports: - "9000" volumes: - ./app:/var/www working_dir: /var/www environment: XDEBUG_CONFIG: remote_host=192.168.50.75 #Подставить свой удаленный IP PHP_IDE_CONFIG: "serverName=docker" MYSQL_DATABASE: test200 MYSQL_ROOT_PASSWORD: root db: container_name: test200 build: ./docker/mysql ports: - "3306:3306" environment: MYSQL_DATABASE: test200 MYSQL_ROOT_PASSWORD: root volumes: - ./docker/mysql/mysql-data:/var/lib/mysql - ./docker/mysql/dumps:/docker-entrypoint-initdb.d There is one line in the mysql dockfile: FROM mysql:latest
in the dumps folder that is linked to the container is a simple sql file:
create database test; use test; CREATE TABLE testtab ( id INTEGER AUTO_INCREMENT, name TEXT, PRIMARY KEY (id) ) COMMENT='this is my test table'; In general, the problem is that after running docker-compose up -d --build new test database docker-compose up -d --build not be created with a test table ... Before each check, it would delete the collected docker-compose rm -f containers docker-compose rm -f . I ask for help
Upd: Here is the link to the dock of this feature https://hub.docker.com/_/mysql/ (closer to the bottom of the page is the subtitle Initializing a fresh instance )
./docker/mysql/dumps/mysql.sql:/docker-entrypoint-initdb.d/mysql.sql? - Senior Pomidor