Deploying Docker containers to Azure Container Apps is a modern, scalable approach for running microservices and containerized applications in the cloud. Azure Container Apps provides a fully managed serverless container platform that enables developers to deploy Docker images without managing Kubernetes infrastructure. This guide explains step-by-step how to deploy Docker containers to Azure Container Apps using Azure CLI, Docker, and Azure Container Registry.
What is Azure Container Apps?
Azure Container Apps is a serverless container hosting service on Microsoft Azure that allows you to run containerized applications without managing servers or orchestrators. It is built on Kubernetes and supports auto-scaling, revisions, traffic splitting, and integration with Azure services.
Key capabilities include:
Serverless container deployment
Automatic scaling based on HTTP traffic or events
Built-in HTTPS and domain support
Support for microservices architecture
Integration with Azure Container Registry (ACR)
Prerequisites
Before deploying Docker containers to Azure Container Apps, ensure the following tools are installed and configured:
Login to Azure using:
az login
Step 1: Create a Resource Group
A resource group is required to organize Azure resources.
az group create --name my-containerapp-rg --location centralindia
You can replace centralindia with your preferred Azure region for geo-targeted deployment.
Step 2: Create Azure Container Registry (Optional but Recommended)
If your Docker image is not public, push it to Azure Container Registry.
az acr create --resource-group my-containerapp-rg \
--name mycontainerregistry \
--sku Basic
Login to ACR:
az acr login --name mycontainerregistry
Tag your Docker image:
docker tag myapp:latest mycontainerregistry.azurecr.io/myapp:latest
Push the image:
docker push mycontainerregistry.azurecr.io/myapp:latest
Step 3: Create a Container Apps Environment
Azure Container Apps require an environment that acts as a secure boundary around deployed apps.
az containerapp env create \
--name my-containerapp-env \
--resource-group my-containerapp-rg \
--location centralindia
Step 4: Deploy Docker Container to Azure Container Apps
Deploy the container image using Azure CLI.
For a public Docker image:
az containerapp create \
--name my-containerapp \
--resource-group my-containerapp-rg \
--environment my-containerapp-env \
--image nginx \
--target-port 80 \
--ingress external
For a private image stored in Azure Container Registry:
az containerapp create \
--name my-containerapp \
--resource-group my-containerapp-rg \
--environment my-containerapp-env \
--image mycontainerregistry.azurecr.io/myapp:latest \
--target-port 80 \
--ingress external \
--registry-server mycontainerregistry.azurecr.io
After deployment, Azure will generate a public URL for your containerized application.
Step 5: Configure Scaling Rules
Azure Container Apps supports automatic scaling based on HTTP traffic or custom rules.
Example configuration:
az containerapp update \
--name my-containerapp \
--resource-group my-containerapp-rg \
--min-replicas 1 \
--max-replicas 5
This enables horizontal scaling between 1 and 5 replicas based on demand.
Step 6: Monitor and Manage Container Apps
You can monitor logs using:
az containerapp logs show \
--name my-containerapp \
--resource-group my-containerapp-rg
Azure Container Apps integrates with Azure Monitor and Application Insights for advanced monitoring and observability of container workloads.
Best Practices for Deploying Docker Containers to Azure
Use multi-stage Docker builds to reduce image size
Store secrets securely using Azure Key Vault
Enable HTTPS and custom domains
Configure proper CPU and memory allocation
Implement CI/CD pipelines using GitHub Actions or Azure DevOps
When to Use Azure Container Apps
Azure Container Apps is ideal for:
Microservices-based architecture
Event-driven applications
Background processing jobs
APIs built with ASP.NET Core
Scalable web applications deployed via Docker
Summary
Deploying Docker containers to Azure Container Apps provides a fully managed, serverless container platform that eliminates infrastructure management while supporting auto-scaling, secure networking, and seamless integration with Azure services. By creating a resource group, configuring Azure Container Registry, setting up a Container Apps environment, and deploying your Docker image through Azure CLI, you can efficiently host scalable containerized applications in the cloud. With built-in monitoring, scaling rules, and DevOps integration, Azure Container Apps is a powerful solution for modern cloud-native and microservices-based deployments.