docker-entrypoint.sh 文件的用处
参考出处 很多著名库的 Dockerfile 文件中,通常都是 ENTRYPOINT 字段会是这样: ENTRYPOINT ["docker-entrypoint.sh"] 这里我们参考分析下 MySQL 的 Dockerfile 文件,来认识下 docker-entrypoint.sh 的用处。 MySQL 8.0 Dockerfile 网址: https://github.com/docker-library/mysql/tree/223f0be1213bbd8647b841243a3114e8b34022f4/8.0 里面的 Dockerfile 、 docker-entrypoint.sh 都写了很多的 shell 代码 这里通过 1 个例子,快速的了解 docker-entrypoint.sh 的使用方法 例子:MySQL 容器自建数据库 网址: https://hub.docker.com/_/mysql/ 中,章节[ Initializing a fresh instance ] 中提到,可以在MySQL容器启动时,初始化自定义数据库: When a container is started for the first time, a new database with the specified name will be created and initialized with the provided configuration variables. Furthermore, it will execute files with extensions .sh, .sql and .sql.gz that are found in /docker-entrypoint-initdb.d. Files will be executed in alphabetical order. You can easily populate your mysql services by mounting a SQL dump into that directory and provide custom images with contributed data. SQL file...