The cli arg -u <uid>:<gid> translates to the service/container property user: <uid>:<gid> in the compose file.
The other approach would be to find out which uid is actually used by the process inside the container, and align the owner of your host folders to uss the same:
> docker run -d --rm --name test clickhouse/clickhouse-server:24.3.5.46
d343030860382553f8fcc997a0b9fdde36daf2f8b80a46047d406721eceea432
> docker exec test ps auxn
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
101 1 35.0 2.5 6530096 417204 ? Ssl 14:18 0:01 /usr/bin/clickhouse-server --config-file=/etc/clickhouse-server/config.xml
0 704 0.0 0.0 8896 3168 ? Rs 14:18 0:00 ps auxn
> docker exec test id 101
uid=101(clickhouse) gid=101(clickhouse) groups=101(clickhouse)
> docker stop test
Now we know that clickhouse is started with uid=101, gid=101. Now you can change the permissions to this owner: chown 101:101 -r ch_data and chown 101:101 -r ch_logs. Note: make sure to be in the folder where the compose file is located, as the chown commands expect you to be in the folder.