P1: Create container image
Create a Dockerfile in root folder, add the content (change accordingly).
FROM node:x.x.x-*******
RUN mkdir -p /usr/src/app
COPY ./app/* /usr/src/app/
WORKDIR /usr/src/app
RUN npm install
CMD node /usr/src/app/index.js
Build image using docker build
docker build ./project-name -t project-app-name
Check container image docker images
Running container locally
docker run -d -p 8080:<PORT> project-app-name
P2: Pushing image to Azure Container Registry
Create a resource group with the az group create
command
az group create --name myResourceGroup --location eastus
Create an Azure container registry with the az acr create
command
az acr create --resource-group myResourceGroup --name <acrName> --sku Basic
Login to container registry
az acr login --name <acrName>
Get the full login server name for the Azure container registry
az acr show --name <acrName> --query loginServer --output table
az acr show --name notchacr --query loginServer --output table
Now, display the list of local images with docker images
command
Tag the image with the login server of your container registry.
docker tag project-app-name <acrLoginServer>/aci-tutorial-app:v1
Confirm with docker images
Finally, push image to Azure Container Registry
docker push <acrLoginServer>/project-app-name:v1
docker push notchacr.azurecr.io/project-app-name:v1
Verify pushed images with
az acr repository list --name <acrName> --output table
az acr repository list --name notchacr --output table
P3: Deploy container application to Azure Container Instances
Just create a new ACI through the Azure portal (portal.azure.com
), select the ACR, app name, etc. DON"T forget to add a DNS label name if you want to connect to a (sub)domain eventually. EZ & straightforward.