Hello Everyone,
This post contains below list of topics
- How to create ACR ( Azure Container Registry )
- How to login into ACR
- How to push Docker images into ACR
- How to build docker images with ACR
# Login
az login --username "xxxx" --password "xxxx"
# Get the resource group name
az group list
# if you want to set subscription
az account set --subscription "SUB NAme"
# create a rg
az group create \
--name psdemo-rg \
--location centralus
# or list existing with
az group list
# Set ACR name , globally unique
ACR_NAME="GRSR810"
az acr create \
--resource-group "1-028b2503-playground-sandbox" \
--name $ACR_NAME \
--sku Standard
# login into ACR
az acr login --name $ACR_NAME
# Get the login server which is used in the image tag
az acr show --name $ACR_NAME --query loginServer
az acr show --name $ACR_NAME --query loginServer --output tsv
ACR_LOGINSERVER=$(az acr show --name $ACR_NAME --query loginServer --output tsv)
echo $ACR_LOGINSERVER
Tag the container image using the login server name.
docker image ls webappimage:v1
docker tag webappimage:v1 $ACR_LOGINSERVER/webappimage:v1
docker image ls $ACR_LOGINSERVER/webappimage:v1
docker image ls
# Push the image into Docker registry
docker push $ACR_LOGINSERVER/webappimage:v1
# Get list of the repositories and images/tags from ACR
az acr repository list --name $ACR_NAME --output table
az acr repository show-tags --name $ACR_NAME --repository webappimage --output table
# By using tasks we can build ACR with tasks.
az acr build --image "webappimage:v1-acr-task" --registry $ACR_NAME .
# 2 images must be there now
az acr repository show-tags --name $ACR_NAME --repository webappimage --output table
Dockerfile
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
RUN mkdir /app
WORKDIR /app
COPY ./webapp/bin/Release/netcoreapp3.1/publish ./
COPY ./config.sh ./
RUN bash config.sh
EXPOSE 80
ENTRYPOINT [ "dotnet", "webapp.dll" ]
Building dotnet Web application
ls -ls ./webapp
dotnet build ./webapp
dotnet run --project ./webapp
curl http://localhost:5000
# Publish local build
dotnet publish -c Release ./webapp
# build docker image
docker build -t webappimage:v1 .
# Run the container
docker run --name webapp --publish 8080:80 --detach webappimage:v1
curl http://localhost:8080
docker stop webapp
docker rm webapp
docker image ls webappimage:v1
0 comments:
Post a Comment