docker - Docker - transfer image of database with its content
问题描述
I want to pull an image of yandex/clickhouse-server
Then do with the database some stuff like creating tables, populate it with data and etc
And then I want to transfer the image with all its content to server.
How should I do this ?
解决方案
我的第一个想法是创建图像快照,docker commit CONTAINER
但这不是干净的解决方案。
正确的方法是创建一些初始化文件并扩展基本图像。在 docker文档页面上。
如何扩展此映像 如果您想在从该映像派生的映像中进行额外的初始化,请在 /docker-entrypoint-initdb.d 下添加一个或多个 *.sql、*.sql.gz 或 *.sh 脚本。在入口点调用 initdb 之后,它将运行任何 *.sql 文件,运行任何可执行的 *.sh 脚本,并在该目录中找到任何不可执行的 *.sh 脚本,以便在启动服务之前进行进一步的初始化。
例如,要添加额外的用户和数据库,请将以下内容添加到 /docker-entrypoint-initdb.d/init-db.sh:
推荐阅读
- python - Python Selenium 获取元素未找到该元素
- php - Laravel 国家代码和电话号码验证
- excel - 如何通过从下一列的单元格中选择年份来填充 Excel 中日期为 30/06/YEAR 的空白单元格
- c++11 - 使用 c++11 编译的 ros kinetic 似乎不起作用
- tomcat - 服务注册表 ping 失败,将重试。错误:获取“http://localhost:8040/access/api/v1/system/ping”:拨号 tcp [::1]:连接:连接被拒绝
- python - 我如何找出特定城市的县人口普查区
- r - 如何使 ar 绘图上的 y 轴以带逗号的十进制格式显示数字?
- java - 在没有模型的情况下使用 th:object
- firebase - 如何使用 Firebase 内置功能而不是 ORM?
- database - Asp.net 核心数据库数据显示的频率高于现有数据