ZooKeeper, ClickHouse Docker MacOS

ZooKeeper

The issue with zookeeper is chmod the mounted volume and got permission denied when running as root. But if run as default user, it got permission denied when trying to read config. Here is a simple solution, create a Dockerfile:

# Use the base image
FROM bitnami/zookeeper:3.7.1

# Switch to root user to change permissions
USER root

# Change ownership or permissions of /opt/bitnami
RUN chown -R 1001:1001 /opt/bitnami && chmod -R 775 /opt/bitnami

# Switch back to the non-root user
USER 1001

And build the image with:

$ docker build -t custom-zookeeper:3.7.1 .

ClickHouse

ClickHouse also perform chmod on its startup and can cause permission denied. The helpful solution could be useful from here: https://clickhouse-experts.com/blog/2021/03/20/clickhouse-container-permissions-and-faster-startup/

Define environment variables:

CLICKHOUSE_DO_NOT_CHOWN=1
CLICKHOUSE_UID=101
CLICKHOUSE_GID=101

These is solution for image clickhouse/clickhouse-server:24.1.2-alpine.