Monday, January 24, 2022

Deploy Docker Container in Azure using Azure CLI

Description: Here I have explained, How to deploy container in Azure using Azure CLI in Windows client machine 

Pre-requisites:

  1. Azure CLI [Download and Install Azure CLI using Link]
  2. Azure Subscription 
  3. Docker Hub install in  Windows Machine [Download and Install using Link]
Run the Docker Container on ACI

  • The first step is to login into Azure using Azure CLI using az login command and it will pop-up for username and password for Azure login
  • Once you log in successfully, it will redirect to CMD 
  • After logging in to Azure, first, we need to create a list of the Azure ACI context using docker context list command
    Note: 
    Docker has the concept of context, it is the place where you can run the docker containers 
  • Create the ACI context using the following

$ docker context create aci servertechaci Here,
servertechaci:
Name of the ACI

  • Once we enter the above command it will ask for the subscription, if there is only one then docker uses it. After that need to select Resource Group 








  • After creating context you can list it and verify 
Run container on ACI: After creating ACI you can run the container using command or using compose file

  • Run container manually: using the below command you can create a container manually
docker --context servertechaci run -d --name web -p 80:80 harpalgohilon/opensource:httpd











Once the container is created successfully, you will receive the container in the list


















Also, browse the URL from container Public IP



















  • Run container using compose file: Below is the compose file to run apache on port 80 using docker image
  • Create compose file and save as test.yml
version: '3.8' services: apache2: image: harpalgohilon/opensource:httpd ports: - "80:80"
  • Run the compose file using the below command
docker compose -f test.yml up -d










































No comments:

Post a Comment