Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save LupusMichaelis/db8dfcb57ca236a7fa24d13311a9d5f1 to your computer and use it in GitHub Desktop.
Save LupusMichaelis/db8dfcb57ca236a7fa24d13311a9d5f1 to your computer and use it in GitHub Desktop.
Launch CockroachDB as a cluster of 3 nodes
# A playground to test CockroachDB
#
# Launch:
# docker compose up
#
# Initialize the first time through the first node:
# docker compose exec first cockroach --host=first:26357 init --insecure
#
# Get dashboard URL from the second node:
# echo http://$(docker compose exec second hostname -i):8080/
#
# Access the SQL console through the third node:
# docker compose exec first cockroach sql --host=third:26257 --insecure
#
x-vars:
tag: &image "cockroachdb/cockroach:v23.1.3"
services:
first:
image: *image
volumes:
- first:/cockroach/cockroach-data:rw
command:
- start
- --advertise-addr=first:26357
- --http-addr=first:8080
- --listen-addr=first:26357
- --sql-addr=first:26257
- --insecure
- --join=first:26357,second:26357,third:26357
second:
image: *image
volumes:
- second:/cockroach/cockroach-data:rw
command:
- start
- --advertise-addr=second:26357
- --http-addr=second:8080
- --listen-addr=second:26357
- --sql-addr=second:26257
- --insecure
- --join=first:26357,second:26357,third:26357
third:
image: *image
volumes:
- third:/cockroach/cockroach-data:rw
command:
- start
- --advertise-addr=third:26357
- --http-addr=third:8080
- --listen-addr=third:26357
- --sql-addr=third:26257
- --insecure
- --join=first:26357,second:26357,third:26357
volumes:
first:
second:
third:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment