Thursday, 3 December 2015

IBM Containers running Spring Boot Applications with IBM Bluemix

There is now a new command line plugin for IBM containers on Bluemix so you can push and run docker images using CF CLI itself. The steps below show you how to set this up and I use a basic spring boot application as a docker image to test this out.


Take a note of the docker local host IP. In this example it was as follows, as I test my docker image on my laptop prior to pushing it to Bluemix.

-> docker is configured to use the default machine with IP

1. Install the latest CF command line, I used the following version.

pasapicella@pas-macbook-pro:~/bluemix_apps/CONTAINERS/ibm-containers/gs-rest-service/complete$ cf --version
cf version 6.14.0+2654a47-2015-11-18

2. Install IBM Containers Cloud Foundry plug-in

pasapicella@pas-macbook-pro:~$ cf install-plugin

**Attention: Plugins are binaries written by potentially untrusted authors. Install and use plugins at your own risk.**

Do you want to install the plugin (y or n)> y

Attempting to download binary file from internet address...
9314192 bytes downloaded...
Installing plugin /var/folders/rj/5r89y5nd6pd4c9hwkbvdp_1w0000gn/T/ibm-containers-mac...
Plugin IBM-Containers v0.8.788 successfully installed.

Note: Default plugin directory as follows


3. Login to IBM Containers

pasapicella@pas-macbook-pro:~/bluemix_apps/CONTAINERS$ cf ic login
Client certificates are being retrieved from IBM Containers...
Client certificates are being stored in /Users/pasapicella/.ice/certs/...
Client certificates are being stored in /Users/pasapicella/.ice/certs/
Client certificates were retrieved.

Deleting old configuration file...
Checking local Docker configuration...

Authenticating with registry at host name
Your container was authenticated with the IBM Containers registry.
Your private Bluemix repository is URL:

You can choose from two ways to use the Docker CLI with IBM Containers:

Option 1: This option allows you to use "cf ic" for managing containers on IBM Containers while still using the Docker CLI directly to manage your local Docker host.
    Use this Cloud Foundry IBM Containers plug-in without affecting the local Docker environment:

    Example Usage:
    cf ic ps
    cf ic images

Option 2: Use the Docker CLI directly. In this shell, override the local Docker environment to connect to IBM Containers by setting these variables. Copy and paste the following commands:
    Note: Only Docker commands followed by (Docker) are supported with this option.

     export DOCKER_HOST=tcp://
     export DOCKER_CERT_PATH=/Users/pasapicella/.ice/certs/
     export DOCKER_TLS_VERIFY=1

    Example Usage:
    docker ps
    docker images
4. View docker images

pasapicella@pas-macbook-pro:~/bluemix_apps/CONTAINERS$ cf ic images
REPOSITORY                                        TAG                 IMAGE ID            CREATED             VIRTUAL SIZE   latest              5996bb6e51a1        6 weeks ago         770.4 MB        latest              ef21e9d1656c        8 weeks ago         528.7 MB                latest              2209a9732f35        8 weeks ago         492.8 MB                   latest              8f962f6afc9a        8 weeks ago         429 MB   latest              131fd7a39dff        11 weeks ago        570 MB

5. Clone application to run as docker image

$ git clone

6. Create a file called Dockerfile as follows in the "complete" directory

pasapicella@pas-macbook-pro:~/bluemix_apps/CONTAINERS/ibm-containers/gs-rest-service/complete$ cat Dockerfile
FROM java:8
ADD target/gs-rest-service-0.1.0.jar app.jar
RUN bash -c 'touch /app.jar'
ENTRYPOINT ["java","","-jar","/app.jar"]

7. Package the demo

$ mvn package

8. Build docker image

pasapicella@pas-macbook-pro:~/bluemix_apps/CONTAINERS/ibm-containers/gs-rest-service/complete$ docker build -t gs-rest-service .
Sending build context to Docker daemon 13.44 MB
Step 1 : FROM java:8
8: Pulling from library/java
1565e86129b8: Pull complete
a604b236bcde: Pull complete
5822f840e16b: Pull complete
276ac25b516c: Pull complete
5d32526c1c0e: Pull complete
0d61f7a71c59: Pull complete
16952eac0a64: Pull complete
2fb3388c8597: Pull complete
ca603b247c8e: Pull complete
1785f2bc7c99: Pull complete
40e61a6ae215: Pull complete
32f541968fe6: Pull complete
Digest: sha256:52a1b487ed34f5a76f88a336a740cdd3e7b4486e264a3e69ece7b96e76d9f1dd
Status: Downloaded newer image for java:8
 ---> 32f541968fe6
Step 2 : VOLUME /tmp
 ---> Running in 030f739777ac
 ---> 22bf0f9356a1
Removing intermediate container 030f739777ac
Step 3 : ADD target/gs-rest-service-0.1.0.jar app.jar
 ---> ac590c46b73b
Removing intermediate container 9790c39eb1f7
Step 4 : RUN bash -c 'touch /app.jar'
 ---> Running in e9350ddebb75
 ---> 697d245c6afb
Removing intermediate container e9350ddebb75
Step 5 : ENTRYPOINT java -jar /app.jar
 ---> Running in 42fc22473930
 ---> df853abfea57
Removing intermediate container 42fc22473930
Successfully built df853abfea57

9. Run locally

pasapicella@pas-macbook-pro:~/bluemix_apps/CONTAINERS/ibm-containers/gs-rest-service/complete$ docker run --name gs-rest-service -p 80:8080 -d -t gs-rest-service

10. Test as follows

pasapicella@pas-macbook-pro:~/bluemix_apps/CONTAINERS/ibm-containers$ curl
{"id":1,"content":"Hello, World!"}

11. PUSH TO BLUEMIX AS follows

pasapicella@pas-macbook-pro:~/bluemix_apps/CONTAINERS/ibm-containers/gs-rest-service/complete$ docker tag gs-rest-service
pasapicella@pas-macbook-pro:~/bluemix_apps/CONTAINERS/ibm-containers/gs-rest-service/complete$ docker push
The push refers to a repository [] (len: 1)
Sending image list
Pushing repository (1 tags)
Image 5822f840e16b already pushed, skipping
Image 276ac25b516c already pushed, skipping
Image 5d32526c1c0e already pushed, skipping
Image a604b236bcde already pushed, skipping
Image 1565e86129b8 already pushed, skipping
Image 0d61f7a71c59 already pushed, skipping
Image 2fb3388c8597 already pushed, skipping
Image 16952eac0a64 already pushed, skipping
Image ca603b247c8e already pushed, skipping
Image 1785f2bc7c99 already pushed, skipping
Image 40e61a6ae215 already pushed, skipping
Image 32f541968fe6 already pushed, skipping
22bf0f9356a1: Image successfully pushed
ac590c46b73b: Image successfully pushed
697d245c6afb: Image successfully pushed
df853abfea57: Image successfully pushed
Pushing tag for rev [df853abfea57] on {}

12. List all allocated IP

pasapicella@pas-macbook-pro:~/bluemix_apps/CONTAINERS/ibm-containers/gs-rest-service/complete$ cf ic ip list
Number of allocated public IP addresses:  2

IpAddress        ContainerId

13. Create a container from the uploaded image

pasapicella@pas-macbook-pro:~/bluemix_apps/CONTAINERS/ibm-containers/gs-rest-service/complete$ cf ic run -p 8080 --memory 512 --name pas-sb-container

14. Assign IP to container

pasapicella@pas-macbook-pro:~/bluemix_apps/CONTAINERS/ibm-containers/gs-rest-service/complete$ cf ic ip bind pas-sb-container
The IP address was bound successfully.

15. Verify it's running

pasapicella@pas-macbook-pro:~/bluemix_apps/CONTAINERS/ibm-containers/gs-rest-service/complete$ cf ic ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                  PORTS                          NAMES
3794802b-b0c                  ""                  4 minutes ago       Running 3 minutes ago>8080/tcp   pas-sb-container

16. Invoke as follows

$ curl

More Information

Plugin Reference ->

Installing cf ci plugin ->