Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clickhouse Client - Code: 62. DB::Exception: Empty query

I'm trying to run clickhouse-server and clickhouse-client services using Docker and Docker Compose. Based on clickhouse docker-compose file and another compose sample, I created the services in my docker-compose.yml file as you can see below:

docker-compose.yml:

    ch_server:
      container_name: myapp_ch_server
      image: yandex/clickhouse-server
      ports:
        - "8181:8123"
        - "9000:9000"
        - "9009:9009"
      ulimits:
        nproc: 65535
        nofile:
          soft: 262144
          hard: 262144
      volumes: 
        - ./ch_db_data:/var/lib/clickhouse/
        - ./ch_db_logs:/val/log/clickhouse-server/
      networks:
        - myapp-network

    ch_client:
      container_name: myapp_ch_client
      image: yandex/clickhouse-client
      command: ['--host', 'ch_server']
      networks:
        - myapp-network

When I run docker-compose up command, the following exception occurs from clickhouse-client service:

myapp_ch_client | Code: 62. DB::Exception: Empty query
myapp_ch_client exited with code 62

Do you have any idea how to fix this error?

like image 398
Ali Tavafi Avatar asked Jan 20 '26 09:01

Ali Tavafi


2 Answers

It just needs to pass the SQL-query in command-params:

version: "2.4"

services:
  ch_server:
    container_name: myapp_ch_server
    image: yandex/clickhouse-server
    ports:
      - "8123:8123"
      - "9000:9000"
      - "9009:9009"
    ulimits:
      nproc: 65535
      nofile:
        soft: 262144
        hard: 262144
    volumes: 
      - ./ch_db_data:/var/lib/clickhouse/
      - ./ch_db_logs:/var/log/clickhouse-server/
    networks:
      - myapp-network
    healthcheck:
      test: wget --no-verbose --tries=1 --spider localhost:8123/ping || exit 1
      interval: 2s
      timeout: 2s
      retries: 16

  ch_client:
    container_name: myapp_ch_client
    image: yandex/clickhouse-client
    command: ['--host', 'ch_server', '--query', 'select * from system.functions order by name limit 4']
    networks:
      - myapp-network
    depends_on:
      ch_server:
        condition: service_healthy

networks:
    myapp-network:

It doesn't make sense to define clickhouse-client in docker-compose. clickhouse-client usually run outside of docker-compose file:

  1. define docker-compose that defines servers (such as ClickHouse (nodes of cluster), Zookeeper, Apache Kafka, etc). For example, let's consider the config with one node of ClickHouse:
version: "2.4"

services:
  ch_server:
    container_name: myapp_ch_server
    image: yandex/clickhouse-server
    ports:
      - "8123:8123"
      - "9000:9000"
      - "9009:9009"
    ulimits:
      nproc: 65535
      nofile:
        soft: 262144
        hard: 262144
    volumes: 
      - ./ch_db_data:/var/lib/clickhouse/
      - ./ch_db_logs:/var/log/clickhouse-server/
    networks:
      - myapp-network
    healthcheck:
      test: wget --no-verbose --tries=1 --spider localhost:8123/ping || exit 1
      interval: 2s
      timeout: 2s
      retries: 16

networks:
    myapp-network:

  1. in the separate terminal run clickhouse-client
cd _folder_where_docker-compose_located

docker-compose exec ch_server clickhouse-client
like image 52
vladimir Avatar answered Jan 22 '26 23:01

vladimir


2021 version as this tutorial https://dev.to/titronium/clickhouse-server-in-1-minute-with-docker-4gf2

  clickhouse-client:
    image: yandex/clickhouse-client:latest
    depends_on:
      - clickhouse-server
    links:
      - clickhouse-server
    entrypoint:
      - /bin/sleep
    command:
      - infinity

the last line command: - infinity mean it will wait you there forever to connect

like image 26
Hiep Tran Avatar answered Jan 22 '26 23:01

Hiep Tran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!