https://hub.docker.com/_/mysql
使用 MYSQL_DATABASE 环境变量就行
This variable is optional and allows you to specify the name of a database to be created on image startup. If a user/password was supplied (see below) then that user will be granted superuser access (corresponding to GRANT ALL) to this database.
这个变量是可选的,允许您指定要在映像启动时创建的数据库的名称。如果提供了用户/密码(见下文),那么该用户将被授予对该数据库的超级用户访问权限(对应于GRANT ALL)。
示例
version: "3"
mysql8:
container_name: mysql8
image: mysql:8.0.34
restart: always
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=Ep7zMmBfXm4y3wx
- MYSQL_DATABASE=image_search_engine
volumes:
- ./volumes/mysql/:/var/lib/mysql
- ./my-custom.cnf:/etc/mysql/conf.d/my-custom.cnf
像上面这样就创建了一个名为 image_search_engine 的默认 database
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。