I would like to setup some MySql tables upon Docker startup, however it doesn't look like it works. Here's my DockerfileMySql
:
FROM mysql
ENV MYSQL_DATABASE football_simulation
COPY initial.sql /docker-entrypoint-initdb.d/
And this is my docker-compose.yml
:
version: '3'
services:
mysql-development:
image: mysql:5.7.30
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: football_simulation
ports:
- "3308:3306"
volumes:
- ./initial.sql /docker-entrypoint-initdb.d/
admin:
image: adminer
ports:
- "8080:8080"
Finally my initial.sql
:
CREATE TABLE IF NOT EXISTS tournament
( id INTEGER NOT NULL PRIMARY KEY,
`name` VARCHAR(255) NOT NULL
);
I run docker build .
and docker-compose up
and go over to localhost:8080
, the UI is up with football_simulation
database setup, but with no tables inside. What am I doing wrong?