Skip to Content
Technical Articles
Author's profile photo Akshay Nayak

Deploy an application using Docker Container onto SAP Cloud Platform Cloud foundry

This blog will help you to understand the basics of docker usage with Sap Cloud Platform cloud foundry.

You will create a docker image and will be deploying a Java application running on tomcat server inside a  docker container on your local machine .

Finally you will be deploying this application to SCP cloud foundry using Dockerhub as an intermediate layer.




Make sure that docker is installed and running on your machine. Use the command docker -v


Please download the Dockerfile and the helloworld java application (named ROOT.war) from

Your folder should have 2 files . Please don’t change the file names as there are dependencies.

  1. Dockerfile
  2. ROOT.war


Use the below command to create a docker image based on the instructions from the Dockerfile with a tag “my_docker_image”. Don’t forget the  “.”  in the end.

docker build -t=”my_docker_image” .


You can use the command docker images to find the docker images in your system as shown below.

At this moment, only the docker image is created from the docker file and the container is not running .Use the below command to confirm the same.

docker container ls



Start docker container with port forwarding using the below command.

docker run -p 8080:8080 my_docker_image

Now, you will see that the container has started and the application is running on tomcat server inside the container.

In order to run the application, Open a browser(say chrome) and goto http://localhost:8080/

This is a simple helloworld app which displays date & time.


Use the command docker container ls to find the list of containers running in your system.

You can stop the container if needed using the below command from another terminal.

docker stop 93f1bbd5d52f          (i.e docker stop container_id)

Step 5.

In the previous steps (1 to 4) , you built a docker image from a docker file and then created a docker container and finally deployed a java application on tomcat running inside a docker container. Now , we will push this image to dockerhub and then finally deploy it to cloud foundry.


Step 5a : Create an account on .

Goto terminal and login using the command docker login

This will ask for user name and password. ( created in step 5a)

Step 5b:   Use the docker tag command to tag the image. My username is nayakkrec. Going forward, you should enter your username accordingly .

docker tag my_docker_image nayakkrec/my_docker_image_v1


Step 5c : Use the docker push command to push the image to dockerhub.

docker push nayakkrec/my_docker_image_v1


You can confirm this by visiting



Now, you have successfully pushed the image from your local machine to docker hub.


Step 6:  We will now push the docker image from docker hub and deploy it on cloud foundry.

Goto your SCP cloud foundry account. If you don’t have one, create a trial account at


Goto the overview page to find the cloud foundry api end point.

Use the below command to set the api end point.

cf api

Then login to cloud foundry using the  cf login command with your email and password.


Step 7 :

The final step is to push the docker image from docker hub to cloud foundry and start the application. Please use the below command to achieve the same.

CF_DOCKER_PASSWORD=MyDockerHubPassword cf push my_docker_appv1 –docker-image nayakkrec/my_docker_image_v1:latest –docker-username nayakkrec

Please note that, MyDockerHubPassword is the password of your dockerhub account.  In my case, nayakkrec is my dockerhub username. You need to put your username & password accordingly.



Finally , The app is deployed and started on SCP cloud foundry!!!



Congratulations !!


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Tuncer Gorgun
      Tuncer Gorgun


      It is a very clear and helpful document.



      Author's profile photo Bert Deterd
      Bert Deterd

      Can we use docker-compose to deploy to SCP/Cloud Foundry? Or is a single image deploy with --docker-image the only option ?

      Author's profile photo Luca Toldo
      Luca Toldo

      Hi Bert, as far as I know, one cannot use docker-compose.

      Author's profile photo Alfonso Armenta
      Alfonso Armenta

      This is all very interesting, but is it possible for docker-built services deployed in SAPCP to listen on different tcp ports (and not necessarily using HTTP)?


      Author's profile photo Joachim Van Praet
      Joachim Van Praet

      When reading the cloudfoundry documentation I saw that Cloud Foundry supports only one exposed port on the image.

      By Adding EXPOSE in the dockerfile, you can define which port is exposed for which protocol.



      Author's profile photo Akshat Ahuja
      Akshat Ahuja


      Thanks for the post, it really helped me in getting started with dockers in CF.

      I didn't find your github repository so I used this one(

      It runs locally, and I have uploaded it too on dockerhub( just to test cf before deploying my own docker.

      But I got this error:

      Creating app my_docker_image_appv101...
      You are not authorized to perform the requested action

      I just wanted to know if CF still supports pushing docker image.

      It'll be great if you could help me.