Install ClickHouse Inside Docker Container on Linux

Install ClickHouse Inside Docker Container on Linux

ClickHouse is an open-source column-oriented database management system for online analytical processing (OLAP) of queries.

This tutorial explains how to install ClickHouse inside a Docker container on Linux. Commands have been tested on Ubuntu.

Prepare environment

Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.

Install ClickHouse

  • Host network

Run the following command to create a container for ClickHouse that uses host network:

docker run -d --name=clickhouse --restart=always --network=host \
    --ulimit nofile=262144:262144 \
    -v /opt/clickhouse/data:/var/lib/clickhouse \
    -v /opt/clickhouse/log:/var/log/clickhouse-server \
    -e CLICKHOUSE_USER=admin \
    -e CLICKHOUSE_PASSWORD=pwd123 \
    clickhouse/clickhouse-server
  • User-defined bridge network

User-defined bridge network can be used for listening on different port. By default, the ClickHouse service listens on port 8123 for the HTTP interface, on port 9000 for the native client, and on port 9009 for inter-server communication. These ports can be changed with -p option.

docker network create app-net
docker run -d --name=clickhouse --restart=always --network=app-net \
    -p 8080:8123 \
    -p 8081:9000 \
    -p 8082:9009 \
    --ulimit nofile=262144:262144 \
    -v /opt/clickhouse/data:/var/lib/clickhouse \
    -v /opt/clickhouse/log:/var/log/clickhouse-server \
    -e CLICKHOUSE_USER=admin \
    -e CLICKHOUSE_PASSWORD=pwd123 \
    clickhouse/clickhouse-server

Note: don't forget to change user password.

Testing ClickHouse

To access the web UI, navigate to http://<IP_ADDRESS>:8123/play, replacing <IP_ADDRESS> with the system's IP address.

ClickHouse Inside Docker Container on Linux

Uninstall ClickHouse

To completely remove ClickHouse, remove its container:

docker rm --force clickhouse

Remove ClickHouse image:

docker rmi clickhouse/clickhouse-server

You can also remove ClickHouse data:

sudo rm -rf /opt/clickhouse

If a user-defined bridge network was created, you can delete it as follows:

docker network rm app-net

Leave a Comment

Cancel reply

Your email address will not be published.