heidloff.net - Building is my Passion

Deploying a Spring Boot Application to Bluemix in 20 Minutes via Docker

I really want to learn more about the Java framework Spring. The simplicity to build enterprise applications together with Spring’s momentum makes it really interesting. So I started with a simple tutorial and deployed that Spring application to Bluemix.

Spring provides a simple hello world Spring Boot with Docker tutorial with a Spring Boot application with one REST API. Maven and Gradle can be used, not only to build the Java application but also a Docker image which can be deployed to Bluemix.

The Spring tutorial states that you need 15 minutes for the tutorial. In my case that was true since I had the prerequisites JDK 1.8, Maven and Docker already installed. For the deployment of the application you don’t need more than 5 additional minutes.

I won’t repeat all the steps from the Spring tutorial here, but essentially this is what you need to do:
– Clone a Github project. Use the ‘complete’ version of the application
– Build the project via Maven or Gradle
– Optional: Run the application locally: Run the built jar file which comes with Tomcat and your application
– Build the Docker image via Maven or Gradle plugins

The tutorial describes how to push the image to Docker Hub (via “docker push springio/gs-spring-boot-docker”). To push the image to Bluemix follow the next steps instead.

> cf login
> cf ic login
> docker tag springio/gs-spring-boot-docker registry.ng.bluemix.net/nheidloff/gs-spring-boot-docker <- change the namespace
> docker push registry.ng.bluemix.net/nheidloff/gs-spring-boot-docker <- change the namespace

After this you’ll see the image on Bluemix.


In order to run a container invoke these commands:

> cf ic run –name gs-spring-boot-docker -p 8080:8080 -d -t registry.ng.bluemix.net/nheidloff/gs-spring-boot-docker <- change the namespace
> cf ic ip request
> cf ic ip list -a
> cf ic ip bind gs-spring-boot-docker <- change the IP

Alternatively you can use the Bluemix UI to create a container. Choose the new image, define the port 8080 and bind an IP address.

Open the application in a web browser via yourIP:8080.

Featured Blog Posts
The postings on this site are my own and don’t necessarily represent IBM’s positions, strategies or opinions.
Trending Tags