This is about building containers and deploying them using Docker Compose on your local machine, respectively at Azure as a Container Instance.
For a more detailed manual please see the related blog post:
https://www.patrickkoch.dev/posts/post_20/
Prerequisites:
- Docker Compose
- Active Azure Subscription
After cloning the repository, the containers can be builded by using the "docker build" command.
Start e.g.: a Windows PowerShell, change the directory to "first-linux-container" and run:
docker build -t first-linux-container .
After that, change the directory to "second-linux-container" and run:
docker build -t second-linux-container .
This will create the container images.
Change the directory to "docker-compose-yaml-files\local" and run following command:
docker compose up
This will run two containers, refering to the container images builded before. You can prove that by running:
docker ps
Run following command for terminating the containers:
docker compose down
In contrast to the previous approach, this aims to deploy the containers in Azure as Container Instance. As prerequisite for that, you need an active Azure subscription.
az login
Tag the container images, so they fit to be pushed to the Container Registry:
docker tag <Image ID> <Container Registry Name>.azurecr.io/containergroup:first-linux-container
docker tag <Image ID> <Container Registry Name>.azurecr.io/containergroup:second-linux-container
Use following command to login to your Container Registry, which will manage your Container Images:
az acr login --name <Container Registry Name>
Afterwards, push the Container Images using:
docker push <Container Registry Name>.azurecr.io/containergroup:first-linux-container
docker push <Container Registry Name>.azurecr.io/containergroup:second-linux-container
Create a new ACI context by applying following command:
docker context create aci patricksacicontext
In addition, switch to that context:
docker context use patricksacicontext
Adapt the Docker-Compose-YAML file, due to the name of the pushed Container Images, respectively the name of the Container Registry:
version: "3.9"
services:
first-linux-container:
image: <Container Registry Name>.azurecr.io/containergroup:first-linux-container
second-linux-container:
image: <Container Registry Name>.azurecr.io/containergroup:second-linux-container
Afterwards, apply the very same "docker compose" commands for deploying/terminating the containers:
docker compose up
docker compose down
The containers will be deployed as an "Azure Container Instance".