Overview:

Web App for Containers provides a flexible way to use Docker images. This post shows how to deploy a multi-container app (preview) to Web App for Containers in the Cloud Shell using a Docker Compose configuration.

Azure App Service offers a quick and efficient way to deploy multi-container apps using Docker Compose configurations. This quickstart guide walks you through deploying a sample multi-container app, which includes a WordPress site with a MySQL database, to Azure App Service.

Key steps include:

  • Using the Bash environment in Azure Cloud Shell.
  • Downloading the sample compose file from Docker.
  • Creating a resource group as a logical container for Azure resources.
  • Creating an Azure App Service plan.
  • Deploying the app using the az webapp create command with the Docker Compose file.

The guide emphasizes the use of sidecar containers (preview) as the successor to multi-container apps in App Service, offering more flexibility and control over containerized applications.

Demo

Clone the application

 In the Cloud Shell, create a quickstart directory and then change to it.

C:\Users\metra\source\repos\Labs\AKS – ACR – DevOps\webapp and db\multicontainerwordpress\multicontainerwordpress

mkdir multicontainerwordpress

cd $HOME/multicontainerwordpress

Next, run the following command to clone the sample app repository to your quickstart directory. Then change to the multicontainerwordpress directory.

git clone https://github.com/Azure-Samples/multicontainerwordpress

cd multicontainerwordpress

Create a resource group

az group create --name myResourceGroup --location "South Central US"

Create an Azure App Service plan

az appservice plan create --name myAppServicePlan --resource-group myResourceGroup --sku S1 --is-linux

Create a Docker Compose app

For this post, you use the compose file from Docker.

The configuration file can be found at Azure Samples.

version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
volumes:
    db_data:
az webapp create --resource-group myResourceGroup --plan myAppServicePlan --name <app_name> --multicontainer-config-type compose --multicontainer-config-file compose-wordpress.yml

 

Browse to the app

 Congratulations, you’ve created a multi-container app in Web App for Containers.

Conclusion

In conclusion, Azure App Service’s support for multi-container applications represents a significant advancement in cloud application deployment, offering a robust platform for developers to deploy and manage containerized applications with ease and confidence. 🚀🔐👨‍💻

References:

https://learn.microsoft.com/en-us/azure/app-service/quickstart-multi-container

Leave a Reply

Discover more from Rajeev Singh | Coder, Blogger, YouTuber

Subscribe now to keep reading and get access to the full archive.

Continue reading