se necesitara crear 3 archivos:
Dockerfile:
FROM mysql:5.7COPY ./scripts//docker-entrypoint-initdb.d/
el archivo script.sql debera estar en la ruta(relativa) ./scripts/scripts.sql
docker-compose.yml :
version:'3.3'services: db: build: .
restart: always
environment: MYSQL_DATABASE:'amazonviewer'# So you don't have to use root, but you can if you like MYSQL_USER:'amazonviewer'# You can use whatever password you like MYSQL_PASSWORD:'amazonviewer'# Password for root access MYSQL_ROOT_PASSWORD:'password' ports:# <Port exposed> : < MySQL Port running inside container> -'3306:3306' expose:# Opens port 3306 on the container -'3306'
se deberá tener al final una estructura similar a esta:
-Dockerfile
-docker-compose.yml
-scripts/
-script.sql
para levantar el contenedor se ejecuta el comando docker-compose up
espero les sirva 😉