Spring Boot Kotlin + Docker Compose

This article is next for Spring Boot Kotlin + Docker.

Above entry explains how to create Spring Boot with Kotlin and prepare Dockerfile

Build and start container.

Start command is long, and


Docker Compose

Docker Compose is a tool for defining and running multi-container Docker applications

The use case

  • docker run command is long
  • Start multiple container at the same time

Prepare definition in docker-compose.yml under workspace.

This is YAML file.

Prepare YAML file

Let’s prepare docker-compose.yml.

Previous blog, I use following command to run docker container.

docker run -p 9000:9000 springapp --server.port=9000

To do same in docker-compose,

version: '3.8'
    image: springapp
      - '9000:9000'
      - 'server.port=9000'
    tty: true
    stdin_open: true

version is docker compose definition version. Please check this page.

services are start of multiple container definition.

In this file. “web” is only one service. We can add multiple services with name.

Under “web”, there are definitions of above command.

image = image name

ports = port setting

environment = environment variable

tty = -t

stdin_open = -i

Actually last 2 are not required not included above command.

Let’s run

docker-compose up -d

Start docker container with deamon.
You can access localhost:9000/hello.    The result is same as previous blog.
Kotlin Server
Professional Programmer2