Skip to content

Commit

Permalink
Merge pull request #2537 from ClickHouse/ClickHouse-docker-library
Browse files Browse the repository at this point in the history
Update clickhouse docs according to ClickHouse/ClickHouse
  • Loading branch information
tianon authored Feb 6, 2025
2 parents 1a8d578 + 22627cd commit 6c30c75
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions clickhouse/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ By default, starting above server instance will be run as the `default` user wit
### connect to it from a native client

```bash
docker run -it --rm --link some-clickhouse-server:clickhouse-server --entrypoint clickhouse-client %%IMAGE%% --host clickhouse-server
docker run -it --rm --network=container:some-clickhouse-server --entrypoint clickhouse-client %%IMAGE%%
# OR
docker exec -it some-clickhouse-server clickhouse-client
```
Expand All @@ -47,7 +47,7 @@ More information about the [ClickHouse client](https://clickhouse.com/docs/en/in
### connect to it using curl

```bash
echo "SELECT 'Hello, ClickHouse!'" | docker run -i --rm --link some-clickhouse-server:clickhouse-server buildpack-deps:curl curl 'http://clickhouse-server:8123/?query=' -s --data-binary @-
echo "SELECT 'Hello, ClickHouse!'" | docker run -i --rm --network=container:some-clickhouse-server buildpack-deps:curl curl 'http://localhost:8123/?query=' -s --data-binary @-
```

More information about the [ClickHouse HTTP Interface](https://clickhouse.com/docs/en/interfaces/http/).
Expand All @@ -61,11 +61,13 @@ docker rm some-clickhouse-server

### networking

> ⚠️ Note: the predefined user `default` does not have the network access unless the password is set, see "How to create default database and user on starting" and "Managing `default` user" below
You can expose your ClickHouse running in docker by [mapping a particular port](https://docs.docker.com/config/containers/container-networking/) from inside the container using host ports:

```bash
docker run -d -p 18123:8123 -p19000:9000 --name some-clickhouse-server --ulimit nofile=262144:262144 %%IMAGE%%
echo 'SELECT version()' | curl 'http://localhost:18123/' --data-binary @-
docker run -d -p 18123:8123 -p19000:9000 -e CLICKHOUSE_PASSWORD=changeme --name some-clickhouse-server --ulimit nofile=262144:262144 %%IMAGE%%
echo 'SELECT version()' | curl 'http://localhost:18123/?password=changeme' --data-binary @-
```

`22.6.3.35`
Expand All @@ -79,6 +81,8 @@ echo 'SELECT version()' | curl 'http://localhost:8123/' --data-binary @-

`22.6.3.35`

> ⚠️ Note: 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:
Expand Down Expand Up @@ -148,6 +152,16 @@ Sometimes you may want to create a user (user named `default` is used by default
docker run --rm -e CLICKHOUSE_DB=my_database -e CLICKHOUSE_USER=username -e CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 -e CLICKHOUSE_PASSWORD=password -p 9000:9000/tcp %%IMAGE%%
```

#### Managing `default` user

The user `default` has disabled network access by default in the case none of `CLICKHOUSE_USER`, `CLICKHOUSE_PASSWORD`, or `CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT` are set.

There's a way to make `default` user insecurely available by setting environment variable `CLICKHOUSE_SKIP_USER_SETUP` to 1:

```bash
docker run --rm -e CLICKHOUSE_SKIP_USER_SETUP=1 -p 9000:9000/tcp %%IMAGE%%
```

## 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.
Expand Down

0 comments on commit 6c30c75

Please sign in to comment.