Skip to content

innolab demonstration of Docker running a basic Spring Boot Web application.

Notifications You must be signed in to change notification settings

wrochow/docker-demo

Repository files navigation

Making any Spring Boot app run in a Docker container

In the following example, I will use a (ridiculously) basic Spring Boot app. The app is a simple REST web app that outputs the following plain test "Hello Docker World!". The app is running on Tomcat on port 8080 and is packaged as a jar file. The project was named "docker-demo" and the jar file is named "docker-demo".

Prerequisites (My set-up is on Windows)

  • Docker Desktop
  • Java 17 or higher
  • An existing Spring Boot app

Build the Docker image

    docker build --platform linux/amd64 -t docker-demo .

Run the container

docker run -d --rm --name innolab -p 8088:8080 -t docker-demo

This Run Command Explained

-d (aka --detach) Runs container in background and prints container ID. The container needs to be stopped with the Docker Desktop or the docker stop [CONTAINER ID] command. Docker Stop --rm Automatically remove the container when it exits [optional]
--name Assign a name to the container [optional]
-p Publish a container's port(s) to the host. In this case, browsing to port 8088 will redirect to tomcat exposed 8080.
-t Help page says: "Allocate a pseudo-TTY". Not actually correct. This indicates the name of the image to run. [REQUIRED]

About

innolab demonstration of Docker running a basic Spring Boot Web application.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published