Create a Docker Compose File
A docker-compose.
file gives Docker Desktop instructions to spin up one or more containers together.docker pull
, docker build
, and docker run
details.
We'll use the singlestore/cluster-in-a-box
image built by SingleStoreDB and available on Docker Hub.
Create an empty directory and create a file named docker-compose.
inside.
version: '2'services:singlestore:image: 'singlestore/cluster-in-a-box'ports:- 3306:3306- 8080:8080environment:LICENSE_KEY: ${LICENSE}ROOT_PASSWORD: <Secure-password-for-root>START_AFTER_INIT: 'Y'
A YAML file is a text file that’s great for capturing our architecture setup.
Here are the sections in the docker-compose.
file:
-
The services array lists all the containers that will start up together.
A single container is defined here, named singlestore
, which uses thesinglestore/cluster-in-a-box
image built by SingleStore. -
The Ports section identifies inbound traffic that will route into the container.
Open port 3306
for the database engine and port8080
for Studio.If either of these ports are in use on your machine, change only the left port. For example, to connect from outside Docker to the database on port 3307 use 3307:8080
. -
The first environment variable,
START_
, exists for legacy reasons.AFTER_ INIT Without this environment variable, the container will spin up, initialize the SingleStoreDBcluster, and immediately stop. This is great for debugging, but not the point of this guide. -
The second environment variable,
LICENSE
, is the placeholder for the license you got fromportal.
.singlestore. com Don’t copy the license into place here – you’ll accidentally leak secrets into source control. Instead, this syntax notes that you’ll reference an environment variable set in the terminal.
In time, you could easily add you application, business intelligence (BI) dashboard, and other resources to this file.docker-compose.
file, you can copy that content into place here too.
Save the file, and you’re ready to launch Docker.
Last modified: October 16, 2023