Create a Docker Compose File

A docker-compose.yaml file gives Docker Desktop instructions to spin up one or more containers together. It’s a great way to capture all the docker pull, docker build, and docker run details. This file does not replace Dockerfile but rather makes it much easier to use the parameters.

We'll use the singlestore/cluster-in-a-box image built by SingleStore and available on Docker Hub. Pre-installed in this image is the SingleStore database engine and SingleStore Studio. The minimum system requirements are disabled in this "cluster-in-a-box" configuration.

Create an empty directory and create a file named docker-compose.yaml inside. Open this file in your favorite code editor and paste in this content:

version: '2'
image: 'singlestore/cluster-in-a-box'
- 3306:3306
- 8080:8080
ROOT_PASSWORD: <Secure-password-for-root>

A YAML file is a text file that’s great for capturing our architecture setup. As with Python source code, white space is significant. YAML uses two spaces, not tabs. Double-check the YAML file to ensure each section is indented with exactly two spaces. If you have more or fewer spaces, or if you’re using tabs, you’ll get an error on startup.

Here are the sections in the docker-compose.yaml file:

  1. Using Docker Compose syntax Version 2.

  2. The services array lists all the containers that will start up together. A single container is defined here, named singlestore, which uses the singlestore/cluster-in-a-box image built by SingleStore.

  3. The Ports section identifies inbound traffic that will route into the container. Open port 3306 for the database engine and port 8080 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.

  4. The first environment variable, START_AFTER_INIT, exists for legacy reasons. Without this environment variable, the container will spin up, initialize the SingleStorecluster, and immediately stop. This is great for debugging, but not the point of this guide.

  5. The second environment variable, LICENSE, is the placeholder for the license you got from 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. If you have an existing docker-compose.yaml 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

Was this article helpful?