首页 > 解决方案 > 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 ?

标签: dockerclickhouse

解决方案


我的第一个想法是创建图像快照,docker commit CONTAINER但这不是干净的解决方案。

正确的方法是创建一些初始化文件并扩展基本图像。在 docker文档页面上。

如何扩展此映像 如果您想在从该映像派生的映像中进行额外的初始化,请在 /docker-entrypoint-initdb.d 下添加一个或多个 *.sql、*.sql.gz 或 *.sh 脚本。在入口点调用 initdb 之后,它将运行任何 *.sql 文件,运行任何可执行的 *.sh 脚本,并在该目录中找到任何不可执行的 *.sh 脚本,以便在启动服务之前进行进一步的初始化。

例如,要添加额外的用户和数据库,请将以下内容添加到 /docker-entrypoint-initdb.d/init-db.sh:


推荐阅读