Versions
- The
latesttag points to the latest release of the latest stable branch. - Branch tags like
22.2point to the latest release of the corresponding branch. - Full Version tags like
22.2.3and22.2.3.5point to the corresponding release. - The tag
headis built from the latest commit to the default branch. - The tags without a suffix point to the image built
FROM scratch: it contains only ClickHouse and the few system files it needs, without a shell, a package manager, or coreutils. See Image without a shell below. - Each tag has an optional
-ubuntusuffix for the image built on top ofubuntu, with a shell and the usual tools, which runs the shell scriptentrypoint.sh. - Each tag has an optional
-alpinesuffix to reflect that it’s built on top ofalpine. - Each tag has an optional
-distrolesssuffix for the image built on top of a distroless base image, which runs as theclickhouseuser (uid 101) from the start.
Compatibility
- The amd64 image requires support for the x86-64-v3 microarchitecture level (AVX2, BMI1, BMI2, F16C, FMA, LZCNT, MOVBE, XSAVE). Virtually all x86 CPUs after 2015 support x86-64-v3.
- The arm64 image requires support for the ARMv8.2-A architecture and additionally the Load-Acquire RCpc register. The register is optional in version ARMv8.2-A and mandatory in ARMv8.3-A. Supported in Graviton >=2, Azure and GCP instances. Examples for unsupported devices are Raspberry Pi 4 (ARMv8.0-A) and Jetson AGX Xavier/Orin (ARMv8.2-A).
- Since ClickHouse 24.11 Ubuntu images began using
ubuntu:22.04as its base image. It requires docker version >=20.10.10containing patch. As a workaround you could usedocker run --security-opt seccomp=unconfinedinstead, however this has security implications.
How to use this image
Start server instance
default user without password.
Connect to it from a native client
Connect to it using curl
Stopping / removing the container
Networking
the predefined user
default doesn’t have the network access unless the password is set,
see “How to create default database and user on starting” and “Managing default user” below--network=host
(also allows achieving better network performance):
The user default in the example above is available only for the localhost requests
Volumes
Typically you may want to mount the following folders inside your container to achieve persistency:/var/lib/clickhouse/- main folder where ClickHouse stores the data/var/log/clickhouse-server/- logs
/etc/clickhouse-server/config.d/*.xml- files with server configuration adjustments/etc/clickhouse-server/users.d/*.xml- files with user settings adjustments/docker-entrypoint-initdb.d/- folder with database initialization scripts (see below).
Linux capabilities
ClickHouse has some advanced functionality, which requires enabling several Linux capabilities They’re optional and can be enabled using the following docker command-line arguments:Configuration
The container exposes port 8123 for the HTTP interface and port 9000 for the native client. ClickHouse configuration is represented with a file “config.xml” (documentation)Start server instance with custom configuration
Start server as custom user
--user argument and mount /var/lib/clickhouse and /var/log/clickhouse-server inside the container. Otherwise, the image will complain and not start.
Start server from root
Starting the server from root is useful in cases where user namespace is enabled. To do so run:How to create default database and user on start
SetCLICKHOUSE_DB to create a database when the container first initializes the data directory. Set CLICKHOUSE_USER and CLICKHOUSE_PASSWORD to configure a user. If you omit CLICKHOUSE_USER, the image uses the default user.
CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 lets the configured user create users and grant privileges. In the example below, this is username. When you set a non-default username or a password, SQL access management is disabled if you omit this variable or set it to 0.
Managing default user
With the stock configuration, if you use the default user without a password and leave CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT unset or set it to 0, the user retains SQL access management and can connect only from localhost.
CLICKHOUSE_SKIP_USER_SETUP=1 skips user configuration even if you set a username, password, or access-management flag. With the stock configuration, this allows network connections as the default user without a password.
How to extend this image
To perform additional initialization in an image derived from this one, add one or more*.sql, *.sql.gz, or *.sh scripts under /docker-entrypoint-initdb.d. After the entrypoint calls initdb, it will run any *.sql files, run any executable *.sh scripts, and source any non-executable *.sh scripts found in that directory to do further initialization before starting the service.
Scripts under
/docker-entrypoint-initdb.d are executed in alphabetical order by filename. If your scripts have dependencies on each other (for example, a script that creates views must run after the script that creates the referenced tables), ensure your filenames sort in the correct order.CLICKHOUSE_USER & CLICKHOUSE_PASSWORD that will be used for clickhouse-client during initialization.
For example, to add another user and database, add the following to /docker-entrypoint-initdb.d/init-db.sh:
Image without a shell
The default image (the tags without a suffix) is builtFROM scratch. It contains the statically linked clickhouse binary, its configuration, and the few system files it needs: CA certificates, /etc/passwd. There is no shell, no package manager, no C library, and no other programs, so the only software to keep patched is ClickHouse.
The logic of the entrypoint (preparing the directories, creating the user from CLICKHOUSE_USER and CLICKHOUSE_PASSWORD, creating CLICKHOUSE_DB, running the scripts from /docker-entrypoint-initdb.d) is built into the binary as clickhouse docker-init, and is configured with the same environment variables. The differences from the -ubuntu image:
- The
*.sqland*.sql.gzinit scripts work as usual. A*.shscript needs a shell: an executable script is run directly, and a non-executable one is run bysh -e(instead of being sourced), so it stops at the first failed command, like withset -einentrypoint.sh. If there is no shell, the container stops with an error, rather than starting without the initialization. docker run clickhouse/clickhouse-server <command>anddocker execcan run only the ClickHouse tools, such asclickhouse-clientorclickhouse-local.
busybox from the busybox-static package of Debian and Ubuntu:
-ubuntu suffix.
User-defined functions and executable scripts
Executable user-defined functions, theexecutable table function, the Executable table engine and executable dictionaries start programs from user_scripts_path (/var/lib/clickhouse/user_scripts/). The image without a shell can run only statically linked programs, because it has no shell, no interpreter such as Python, and no C library. Mount the programs and the configuration of the functions (a file matching *_function.*ml) into the container:
-ubuntu suffix and install the interpreter:
filesystem_isolation to best_effort. Docker does not let the server create the namespaces it needs unless the container has CAP_SYS_ADMIN, so by default the server runs without the isolation and logs a warning. If the container has CAP_SYS_ADMIN and its security profile allows mounting filesystems, the server isolates itself, and the interpreters, libraries and data of the scripts have to be listed in filesystem_isolation_paths. Driver-based user-defined functions need dynamic_user_defined_executable_functions_path declared as <read_write_executable> when the isolation is in force, and need the tools that the drivers run. See Executable UDFs with filesystem isolation.