Deploying Docker Containers in Cloud Foundry Using a Private Registry

DZone 's Guide to

Deploying Docker Containers in Cloud Foundry Using a Private Registry

In this article, we discuss how to deploy a Docker container to Cloud Foundry using a private registry.

· Cloud Zone ·
Free Resource

In my previous blog, I explained how to create a simple NodeJS application, Dockerize it, and deploy it on IBM Cloud using the public DockerHub as a registry.

This works fine if security is not an issue, but there are some additional advantages of using a private registry, such as the one in IBM Cloud. Not only does it protect your images, it also scans the images for security vulnerabilities.

The IBM registry is available for free to experiment within the IBM Cloud. Even for a Lite Account but beware of limited storage.

If you don’t have an account yet, you can register for a free Lite account - no credit card needed!

You will also need to install the IBM Cloud CLI to interact with the Container Registry. More details on using the IBM Cloud CLI can be found here: https://cloud.ibm.com/docs?tab=develop

To get started with the Container Registry select 'Kubernetes -> Registry' from the navigation bar or go to: https://cloud.ibm.com/kubernetes/registry/main/start

Just follow the instructions for a "Quick Start" to connect to a registry in your region and to do some first testing:


Let's take our simple NodeJS application and save it as server.js:


Create a Dockerfile:


Now we can build a local Docker image:

Plain Text

Next, tag the image with a reference to your Container registry and push it to the IBM Cloud:

Plain Text

We can already see that the vulnerability scanner has scanned the image and reports 3 issues. You can review the issues by requesting a vulnerability assessment for the image:


It's up to you to decide whether you want to take actions to resolve the security issues but for now we'll just go ahead and deploy the image as a Docker container in Cloud Foundry.

Before we can do that we need to create an API key to give Cloud Foundry deployment access to our registry:


Next, we'll set 'CF_DOCKER_PASSWORD' to our 'apikey' and then we are ready to deploy using 'iamapikey'.


When the application is successfully deployed you can verify the correct working :


If you want to know more about automating access to the IBM Cloud Container Registry go to: https://cloud.ibm.com/docs/Registry?topic=Registry-registry_access.

container registry, container security, docker and paas, docker application, docker images, ibm cloud foundry, paas cloud

Published at DZone with permission of Yves Debeer . See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}