My requirement is to create DB and Tables in Clickhouse when I'm bringing it up using docker-compose. If it is mysql, I do it as below :
mysql_1:
image: mysql:5.7.16
environment:
MYSQL_DATABASE: "one"
MYSQL_USER: "one_user"
MYSQL_PASSWORD: "one_user_pass"
MYSQL_ROOT_PASSWORD: "root"
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
volumes:
- ./data/one:/docker-entrypoint-initdb.d
ports:
- "3306:3306"
Is there any way to achieve the same for a Clickhouse instance?
I found a not so clean solution for this. It is basically mounting a host directory into the container and running all the "create tables" and "insert" statements, would be persisted as long as we do not clean up the mounted folder!!
clickhouse:
image: yandex/clickhouse-server:18.10
ports:
- "8123:8123"
- "9000:9000"
volumes:
- ./data/clickhouse/data:/var/lib/clickhouse