Initializing a MySQL Database with Schema in Docker
Issue
Docker users encounter difficulties initializing a MySQL database with a predefined schema using a Dockerfile. Despite following documentation guidelines, the CMD command intended to run the schema script fails, preventing a successful container creation.
Solution
The solution involves a sequential approach:
Example Dockerfile:
FROM mysql:5.7.15 MAINTAINER me ENV MYSQL_DATABASE=<schema_name> \ MYSQL_ROOT_PASSWORD=<password> ADD schema.sql /docker-entrypoint-initdb.d EXPOSE 3306
Additional Notes:
The above is the detailed content of How to Initialize a MySQL Database with a Predefined Schema in a Docker Container?. For more information, please follow other related articles on the PHP Chinese website!