How to initialize mysql container when created on Kubernetes?(在 Kubernetes 上创建时如何初始化 mysql 容器?)
问题描述
我想在容器的 MySQL 上设置初始数据.在docker-compose.yml中,这样的代码可以在运行容器时创建初始数据.
I want to set initial data on MySQL of container. In docker-compose.yml, such code can create initial data when running container.
但是,如何在运行时在 Kubernetes 上创建初始数据?
However, how can I create initial data on Kubernetes when running?
推荐答案
根据 MySQL Docker 镜像 README,与容器启动时数据初始化相关的部分是确保您所有的初始化文件都挂载到容器的/docker-entrypoint-initdb.d
文件夹中.
According to the MySQL Docker image README, the part that is relevant to data initialization on container start-up is to ensure all your initialization files are mount to the container's /docker-entrypoint-initdb.d
folder.
您可以在 ConfigMap
中定义您的初始数据,并像这样在您的 pod 中挂载相应的卷:
You can define your initial data in a ConfigMap
, and mount the corresponding volume in your pod like this:
这篇关于在 Kubernetes 上创建时如何初始化 mysql 容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!