1、创建目录结构
├── config │ ├── config.xml │ ├── docker_related_config.xml │ └── users.xml ├── data ├── docker-compose.yml └── log
2、编辑docker-compose.yml文件
version: '3' services: clickhouse: image: yandex/clickhouse-server:21.3.20-alpine container_name: clickhouse ports: - "8123:8123" - "9000:9000" volumes: # 默认配置 - /docker/clickhouse/config/docker_related_config.xml:/etc/clickhouse-server/config.d/docker_related_config.xml:rw - /docker/clickhouse/config/config.xml:/etc/clickhouse-server/config.xml:rw - /docker/clickhouse/config/users.xml:/etc/clickhouse-server/users.xml:rw - /etc/localtime:/etc/localtime:ro # 运行日志 - /docker/clickhouse/log:/var/log/clickhouse-server # 数据持久 - /docker/clickhouse/data:/var/lib/clickhouse:rw
4、启动:docker-compose -f docker-compose.yml up -d 复制配置文件
docker exec -it clickhouse /bin/bash docker cp clickhouse:/etc/clickhouse-server/config.xml config docker cp clickhouse:/etc/clickhouse-server/users.xml config docker cp clickhouse:/etc/clickhouse-server/config.d/docker_related_config.xml config
5、 修改配置文件
关闭监听地址 ./config/docker_related_config.xml 第3行如下:
<!-- <listen_host>::</listen_host> -->
打开监听地址 ./config/config.xml 第146行如下:
<listen_host>0.0.0.0</listen_host>
查看users.xml文件,在<users></users> 中加入自定义用户dev
<dev> <password>123456</password> <networks incl="networks" replace="replace"> <ip>::/0</ip> </networks> <profile>default</profile> <quota>default</quota> <allow_databases> <database>default</database> </allow_databases> </dev>
6、重新启动服务
docker-compose -f docker-compose.yml up -d
7、连接数据库
标签:xml,compose,server,docker,config,clickhouse From: https://www.cnblogs.com/raorao1994/p/16704352.html