Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
In this tutorial, you prepare a multi-container application to use in Kubernetes. You use existing development tools like Docker Compose to locally build and test the application. You learn how to:
Once completed, the following application runs in your local development environment:
In later tutorials, you upload the container image to an Azure Container Registry (ACR), and then deploy it into an AKS cluster.
This tutorial assumes a basic understanding of core Docker concepts such as containers, container images, and docker
commands. For a primer on container basics, see Get started with Docker.
To complete this tutorial, you need a local Docker development environment running Linux containers. Docker provides packages that configure Docker on a Mac, Windows, or Linux system.
Note
Azure Cloud Shell doesn't include the Docker components required to complete every step in these tutorials. Therefore, we recommend using a full Docker development environment.
The sample application used in this tutorial is a basic store front app including the following Kubernetes deployments and services:
Use git to clone the sample application to your development environment.
git clone https://github.com/Azure-Samples/aks-store-demo.git
Change into the cloned directory.
cd aks-store-demo
The sample application you create in this tutorial uses the docker-compose-quickstart YAML file from the repository you cloned.
services:
rabbitmq:
image: rabbitmq:3.13.2-management-alpine
container_name: 'rabbitmq'
restart: always
environment:
- "RABBITMQ_DEFAULT_USER=username"
- "RABBITMQ_DEFAULT_PASS=password"
ports:
- 15672:15672
- 5672:5672
healthcheck:
test: ["CMD", "rabbitmqctl", "status"]
interval: 30s
timeout: 10s
retries: 5
volumes:
- ./rabbitmq_enabled_plugins:/etc/rabbitmq/enabled_plugins
networks:
- backend_services
order-service:
build: src/order-service
container_name: 'order-service'
restart: always
ports:
- 3000:3000
healthcheck:
test: ["CMD", "wget", "-O", "/dev/null", "-q", "http://order-service:3000/health"]
interval: 30s
timeout: 10s
retries: 5
environment:
- ORDER_QUEUE_HOSTNAME=rabbitmq
- ORDER_QUEUE_PORT=5672
- ORDER_QUEUE_USERNAME=username
- ORDER_QUEUE_PASSWORD=password
- ORDER_QUEUE_NAME=orders
- ORDER_QUEUE_RECONNECT_LIMIT=3
networks:
- backend_services
depends_on:
rabbitmq:
condition: service_healthy
product-service:
build: src/product-service
container_name: 'product-service'
restart: always
ports:
- 3002:3002
healthcheck:
test: ["CMD", "wget", "-O", "/dev/null", "-q", "http://product-service:3002/health"]
interval: 30s
timeout: 10s
retries: 5
environment:
- AI_SERVICE_URL=http://ai-service:5001/
networks:
- backend_services
store-front:
build: src/store-front
container_name: 'store-front'
restart: always
ports:
- 8080:8080
healthcheck:
test: ["CMD", "wget", "-O", "/dev/null", "-q", "http://store-front:80/health"]
interval: 30s
timeout: 10s
retries: 5
environment:
- VUE_APP_PRODUCT_SERVICE_URL=http://product-service:3002/
- VUE_APP_ORDER_SERVICE_URL=http://order-service:3000/
networks:
- backend_services
depends_on:
- product-service
- order-service
networks:
backend_services:
driver: bridge
You can use Docker Compose to automate building container images and the deployment of multi-container applications.
Create the container image, download the RabbitMQ image, and start the application using the docker compose
command:
docker compose -f docker-compose-quickstart.yml up -d
View the created images using the docker images
command.
docker images
The following condensed example output shows the created images:
REPOSITORY TAG IMAGE ID
aks-store-demo-product-service latest 72f5cd7e6b84
aks-store-demo-order-service latest 54ad5de546f9
aks-store-demo-store-front latest 1125f85632ae
...
View the running containers using the docker ps
command.
docker ps
The following condensed example output shows four running containers:
CONTAINER ID IMAGE
f27fe74cfd0a aks-store-demo-product-service
df1eaa137885 aks-store-demo-order-service
b3ce9e496e96 aks-store-demo-store-front
31df28627ffa rabbitmq:3.13.2-management-alpine
To see your running application, navigate to http://localhost:8080
in a local web browser. The sample application loads, as shown in the following example:
On this page, you can view products, add them to your cart, and then place an order.
Since you validated the application's functionality, you can stop and remove the running containers. Do not delete the container images - you use them in the next tutorial.
Stop and remove the container instances and resources using the docker-compose down
command.
docker compose down
In this tutorial, you created a sample application, created container images for the application, and then tested the application. You learned how to:
In the next tutorial, you learn how to store container images in an ACR.
Azure Kubernetes Service feedback
Azure Kubernetes Service is an open source project. Select a link to provide feedback:
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Guided Project - Deploy applications to Azure Kubernetes Service - Training
Welcome to this interactive skills validation experience. Completing this module helps prepare you for the Deploy and manage containers with Azure Kubernetes Service assessment.
Certification
Microsoft Certified: Azure Developer Associate - Certifications
Build end-to-end solutions in Microsoft Azure to create Azure Functions, implement and manage web apps, develop solutions utilizing Azure storage, and more.