Skip to content

Fix: make ClickHouse start in production - #8

Open
mpont91 wants to merge 1 commit into
ent0n29:mainfrom
mpont91:fix/clickhouse-init-dev-user
Open

Fix: make ClickHouse start in production#8
mpont91 wants to merge 1 commit into
ent0n29:mainfrom
mpont91:fix/clickhouse-init-dev-user

Conversation

@mpont91

@mpont91 mpont91 commented Aug 26, 2026

Copy link
Copy Markdown

ClickHouse never comes up with docker-compose.prod.yaml. Two separate causes, both triggered by CLICKHOUSE_PASSWORD, which that file makes mandatory.

1. The IDE user aborts the init run. 001_init.sql ends with:

CREATE USER IF NOT EXISTS intellij IDENTIFIED WITH no_password;

Setting a password takes access management away from the default user, so this fails and takes the whole run with it:

Code: 497. DB::Exception: default: Not enough privileges. To execute this query,
it is necessary to have the grant CREATE USER ON *.*. (ACCESS_DENIED)
(query: CREATE USER IF NOT EXISTS intellij IDENTIFIED WITH no_password;)

No tables are created and the container exits. Local development never hits it because docker-compose.local.yaml sets no password, leaving default unrestricted.

Moved to clickhouse/dev/999_dev_user.sql, mounted only by the local compose. An unauthenticated user has no business in a production schema anyway.

2. The users.d mount collides with the entrypoint. The image writes this exact path when CLICKHOUSE_USER/CLICKHOUSE_PASSWORD are set:

cat <<EOT > /etc/clickhouse-server/users.d/default-user.xml

and the compose file mounts a read-only file over it:

/entrypoint.sh: line 131: /etc/clickhouse-server/users.d/default-user.xml: Read-only file system

Renamed to network-access.xml. Everything in users.d is loaded regardless of filename, so it merges with the generated file instead of fighting it.

Verified. Before: container exits, 0 tables. After, with a password set: container stays up, all 33 init files apply, 162 tables, no intellij user. Local behaviour unchanged.

Two problems stopped the container from ever coming up once
CLICKHOUSE_PASSWORD is set, which docker-compose.prod.yaml requires.

001_init.sql created an unauthenticated IDE user. Setting a password takes
access management away from the default user, so CREATE USER fails with
ACCESS_DENIED and the failure aborts the whole init run: no tables, container
exits. Moved to clickhouse/dev/, mounted only by the local compose, where it
also belongs on its own merits.

The users.d file was mounted read-only at the exact path the image's
entrypoint writes when CLICKHOUSE_USER/CLICKHOUSE_PASSWORD are set. Renamed
to network-access.xml; users.d loads every file regardless of name.

Verified with a password set: container stays up, all 33 init files apply,
162 tables created, no intellij user.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant