@@ -22,6 +22,8 @@ The official [CrateDB Docker image].
2222
2323## Quick start
2424
25+ (container-create-cluster)=
26+
2527### Creating a cluster
2628
2729To get started with CrateDB and Docker, you will create a three-node cluster
@@ -38,8 +40,10 @@ sh$ docker network create crate
3840
3941You should then be able to see something like this:
4042
41- ``` text
43+ ``` shell
4244sh$ docker network ls
45+ ```
46+ ``` text
4347NETWORK ID NAME DRIVER SCOPE
44481bf1b7acd66f bridge bridge local
454951cebbdf7d2b crate bridge local
@@ -55,7 +59,7 @@ container `crate03` will run cluster node `crate03`.
5559
5660You can then create your first CrateDB container and node, like this:
5761
58- ```
62+ ``` shell
5963sh$ docker run --rm -d \
6064 --name=crate01 \
6165 --net=crate \
@@ -82,25 +86,26 @@ Breaking the command down:
8286- Defines the environment variable {ref}` CRATE_HEAP_SIZE <crate-reference:conf-env-heap-size> ` ,
8387 which is used by CrateDB to allocate 1 GB for its heap memory.
8488- Runs the command ` crate ` inside the container with parameters:
85- : - ` network.host ` : The ` _site_ ` value results in the binding of the
86- CrateDB process to a site-local IP address.
87- - ` node.name ` : Defines the node's name as ` crate01 ` (used by
88- master election).
89- - ` discovery.seed_hosts ` : This parameter lists the other hosts in the
90- cluster. The format is a comma-separated list of ` host:port ` entries,
91- where port defaults to setting ` transport.tcp.port ` . Each node must
92- contain the name of all the other hosts in this list. Notice also that
93- any node in the cluster might be started at any time, and this will
94- create connection exceptions in the log files, however all nodes will
95- eventually be running and interconnected.
96- - ` cluster.initial_master_nodes ` : Defines the list of master-eligible
97- node names which will participate in the vote of the first master
98- (first bootstrap). If this parameter is not defined, then it is expected
99- that the node will join an already formed cluster. This parameter is only
100- relevant for the first election.
101- - ` gateway.expected_data_nodes ` and ` gateway.recover_after_data_nodes ` :
102- Specifies how many nodes you expect in the cluster and how many nodes must
103- be discovered before the cluster state is recovered.
89+
90+ - ` network.host ` : The ` _site_ ` value results in the binding of the
91+ CrateDB process to a site-local IP address.
92+ - ` node.name ` : Defines the node's name as ` crate01 ` (used by
93+ master election).
94+ - ` discovery.seed_hosts ` : This parameter lists the other hosts in the
95+ cluster. The format is a comma-separated list of ` host:port ` entries,
96+ where port defaults to setting ` transport.tcp.port ` . Each node must
97+ contain the name of all the other hosts in this list. Notice also that
98+ any node in the cluster might be started at any time, and this will
99+ create connection exceptions in the log files, however all nodes will
100+ eventually be running and interconnected.
101+ - ` cluster.initial_master_nodes ` : Defines the list of master-eligible
102+ node names which will participate in the vote of the first master
103+ (first bootstrap). If this parameter is not defined, then it is expected
104+ that the node will join an already formed cluster. This parameter is only
105+ relevant for the first election.
106+ - ` gateway.expected_data_nodes ` and ` gateway.recover_after_data_nodes ` :
107+ Specifies how many nodes you expect in the cluster and how many nodes must
108+ be discovered before the cluster state is recovered.
104109
105110:::{NOTE}
106111If this command aborts with an error, consult the
@@ -250,10 +255,11 @@ The CrateDB Shell, `crash`, is bundled with the Docker image.
250255
251256If you wanted to run ` crash ` inside a user-defined network called ` crate `
252257and connect to three hosts named ` crate01 ` , ` crate02 ` , and ` crate03 `
253- (i.e. the example covered in the [ Creating a Cluster] section) you could run:
258+ (i.e. the example covered in the {ref}` container-create-cluster ` section)
259+ you could run:
254260
255261``` shell
256- $ docker run --rm -ti \
262+ sh $ docker run --rm -ti \
257263 --net=crate crate \
258264 crash --hosts crate01 crate02 crate03
259265```
@@ -266,7 +272,7 @@ Docker's Compose tool allows developers to define and run multi-container
266272Docker applications that can be started with a single ` docker-compose up `
267273command.
268274
269- Read about Docker Compose specifics [ here ] ( https://docs.docker.com/compose/ ) .
275+ Read about Docker Compose specifics in the [ Docker Compose documentation ] ( https://docs.docker.com/compose/ ) .
270276
271277You can define the services that make up your app in a ` docker-compose.yml `
272278file. To recreate the three-node cluster in the previous example, you can
@@ -357,6 +363,11 @@ In the file above:
357363- The start order of the containers is not deterministic and you want all
358364 three containers to be up and running before the election of the master node.
359365
366+ :::{NOTE}
367+ The `deploy` section is used by Docker Swarm (`docker stack deploy`) and is
368+ ignored by `docker compose up`.
369+ :: :
370+
360371# # Best Practices
361372
362373# ## One container per host
@@ -368,7 +379,7 @@ If you are running one container per machine, you can map the container ports
368379to the host ports so that the host acts like a native installation. For example :
369380
370381` ` ` shell
371- $ docker run -d -p 4200:4200 -p 4300:4300 -p 5432:5432 --env CRATE_HEAP_SIZE=1g crate \
382+ sh $ docker run -d -p 4200:4200 -p 4300:4300 -p 5432:5432 --env CRATE_HEAP_SIZE=1g crate \
372383 crate -Cnetwork.host=_site_
373384` ` `
374385
@@ -380,7 +391,7 @@ this reason, you should mount a persistent `data` directory on your host
380391machine to the `/data` directory inside the container :
381392
382393` ` ` shell
383- $ docker run -d -v /srv/crate/data:/data --env CRATE_HEAP_SIZE=1g crate \
394+ sh $ docker run -d -v /srv/crate/data:/data --env CRATE_HEAP_SIZE=1g crate \
384395 crate -Cnetwork.host=_site_
385396` ` `
386397
@@ -399,7 +410,7 @@ removed.
399410Here is an example of how you could mount the `crate.yml` config file :
400411
401412` ` ` shell
402- $ docker run -d \
413+ sh $ docker run -d \
403414 -v /srv/crate/config/crate.yml:/crate/config/crate.yml \
404415 --env CRATE_HEAP_SIZE=1g crate \
405416 crate -Cnetwork.host=_site_
@@ -408,7 +419,7 @@ $ docker run -d \
408419Here, `/srv/crate/config/crate.yml` is an example path, and should be
409420replaced with the path to your host machine's `crate.yml` file.
410421
411- # # Troubleshooting
422+ # # Healthcheck troubleshooting
412423
413424The official [CrateDB Docker image] ships with a liveness [healthcheck]
414425configured.
@@ -468,9 +479,9 @@ memory, with a heap size of 1 GB, you could configure everything at once. For
468479example :
469480
470481` ` ` shell
471- $ docker run -d \
482+ sh $ docker run -d \
472483 --cpus 1.5 \
473- --memory 1g \
484+ --memory 2g \
474485 --env CRATE_HEAP_SIZE=1g \
475486 crate \
476487 crate -Cnetwork.host=_site_
0 commit comments