This blog post focuses on the deployment of an application using Docker Container on SAP Cloud Platform Cloud Foundry (CF) using Microsoft Azure container registry.
@swap.galgali has published a very nice blog Deploying Docker Application on SAP Cloud Platform Cloud Foundry using AWS ECR and Google Cloud Platform Container Registry on how we can build a docker image locally and publish to SAP Cloud platform using AWS & GCP container registry. Our beloved Azure platform was feeling left out from that blog post so I though why don’t we have a blog post to showcase Azure container repository as well.
What we will do in this blog post:
- Create a container registry on Azure
- Push locally build docker image to Azure Container Registry
- Deploy docker image to SAP Cloud Foundry environment from Azure container registries.
Please go through Swapnil’s blog post to start understanding on building a docker image locally. I will use the same docker image “getting-started”.
Assumptions and Pre-requisites:
- You have gone through Swapnil’s blog post here and have created a local docker image.
- You have access to trial version of Azure portal
- You have installed Azure CLI – download from here
- You have SAP Cloud Foundry CLI installed – download from here.
Step1: Creating container registry in Azure:
Go to Azure Portal and search for container registry.
Click on add and create a new container registry.
Provide Resource group (you can create new) and a unique registry name. Click on Review + Create and Create registry, if validation passes.
Container regitry is successfully created.
Step2: Pushing Image to Azure:
Log-in into your azure account using power-shell (Make sure you have installed Azure CLI from here).
Before pushing and pulling container images, you must log in to the registry instance. run the az acr login command.
az acr login --name <Your container registry name>
Before you can push an image to your registry, you must tag it with the fully qualified name of your registry login server. The login server name is in the format <registry-name>.azurecr.io (all lowercase), for example, mycontainerregistry.azurecr.io.
docker tag docker101tutorial <login-server>/ docker101tutorial:v1
Push Docker image using command below:
docker push <login-server>/ docker101tutorial:v1
After pushing the image to your container registry, remove the hello-world:v1 image from your local Docker environment. (Note that this docker rmi command does not remove the image from the hello-world repository in your Azure container registry.)
docker rmi <login-server>/ docker101tutorial:v1
Your docker image is successfully pushed to your container registry. this can be verified by going back to Azure portal.
Now, you can pull and run the docker101tutorial:v1 container image from your container registry by using docker run:
docker run <login-server>/ docker101tutorial:v1
Step3: Pushing Image to SAP Cloud Foundry:
Now we have image ready to be deployed to Sap cloud foundry environment.
Enable Admin user for container registry. This is required to generate passwords for deploying container image.
Login into CF environment using cf Login.
Use command below to push your docker image to SAP Cloud space.
cf push <app_name_cf> --docker-image sapcontainerreg.azurecr.io/docker101tutorial:v1 --docker-username sapcontainerreg
Enter password obtained from access key section for Admin user.
Application will be deployed to SAP Cloud Foundry Environment.
Test the application by click on url for application.
Once we follow all the steps mentioned above, we will be able to deploy docker containers from Azure on SAP Cloud Platform Cloud Foundry.