BUILDING AND RUNNING MULTI-CONTAINER DOCKER APPLICATION ON LOCAL ENVIRONMENT

  • Azure Kubernetes Service (AKS) manages your hosted Kubernetes environment, making it quick and easy to deploy and manage containerized applications without container orchestration expertise.
  • It also eliminates the burden of ongoing operations and maintenance by provisioning, upgrading, and scaling resources on demand, without taking your applications offline.
  • So before we start digging into Azure Kubernetes Serves practical example, let us understand development environment set up or say Pre-requisites.

Prerequisites

  • Docker for Windows installed on your machine.
  • Docker must be running on Linux containers.
  • Azure CLI 2.0.53 or higher must be installed.
  • Working Azure subscription account is required.

The sample application used in this tutorial is a basic voting app. The application consists of a front-end web component and a back-end Redis instance. The web component is packaged into a custom container image. The Redis instance uses an unmodified image from Docker Hub.

In the first part of this application we will do the following:

  • Clone the application we are going to containerized
  • Run the application on Kubernetes Cluster
  • Make it run on our local environment.

Use git to clone the sample application to your development environment:
git clone https://github.com/Azure-Samples/azure-voting-app-redis.git

Change into the cloned directory.

cd .azure-voting-app-redis

  • Inside the directory is the application source code, a pre-created Docker compose file, and a Kubernetes manifest file. These files are used throughout the demo.
  • Docker Compose can be used to automate building container images and the deployment of multi-container applications.

Use the sample docker-compose.yaml file to create the container image, download the Redis image, and start the application: docker-compose up -d

When completed, use the docker images command to see the created images. Three images have been downloaded or created. The azure-vote-front image contains the front-end application and uses the nginx-flask image as a base. The Redis image is used to start a Redis instance.

docker images

 

Run the docker ps command to see the running containers: docker ps

To see the running application, enter http://localhost:8080 in a local web browser. The sample application loads, as shown in the following example:

  • Now that the application’s functionality has been validated, the running containers can be stopped and removed.
  • Do not delete the container images because in the next part of the demo, the azure-vote-front image is uploaded to an Azure Container Registry instance.

Stop and remove the container instances and resources with the docker-compose down command:

Now, in the second part of the demo, we will push our application to Azure Container Registry.

You can see part two of the demo by going to the link here.