Author : MD TAREQ HASSAN | Updated : 2021/05/20
Prerequisites
Enable docker login to Azure Container Registry (ACR)
- Why?
- For ‘pushing with docker command’ method
- No need if you use
az acr ...
command (it will use your Azure credentials)
- Azure portal > ACR
- Access keys > Admin user: Enable
- Copy Username and password (will be used for
docker login ...
command)
Notes:
- Do not use
:latest
tag, use increamental tag i.e.:101
,:102
etc. - If you use
:latest
tag, then to push changes, you have to delete deployment and create again because K8s does not make any changes unless there is difference in manifest file
Using Visual Studio
- Add your Azure account to Visual Studio (login to Visual Studio using Azure credentials)
- Right click on the project
- Publish > Docker container registry > Azure container registry > Next
- Select Azure Account (top right, if you have multiple azure account)
- Select Subscription, Resource group and registry > Finish
- A publish profile will be created
- Publish
Using Azure CLI
#
# Login to ACR using Azure credentials
#
az acr login --name myacr
#
# Create image and push in a single command
#
az acr build --image myacr.azurecr.io/myapp:latest --registry myacr --file Dockerfile .
Using Docker Command
#
# docker login
#
# ACR push
# id: myacr
# pass: xxxxxyyyyyzzzzz
#
docker login myacr.azurecr.io
myacr # Admin user name
xxxxxyyyyyzzzzz # Admin password
#
# docker image build
#
docker build --tag myacr.azurecr.io/myapp:latest .
#
# docker push
#
docker push myacr.azurecr.io/myapp:latest