Build a Docker Image 1. Create an Azure Container registry (say myreg101). 2. Create a Dotnet app (I am using webapp aspnet core 6.0) 3. Pub...
Build a Docker Image
1. Create an Azure Container registry (say myreg101).
2. Create a Dotnet app (I am using webapp aspnet core 6.0)
3. Publish the code on your local system.
4. Create an azure ubuntu vm and copy-publish code on this machine.
5. Install Docker on ubuntu VM (apt install docker.io -y)
6. Create a Dockerfile in the publish folder with the following code
7. Build a docker image(webimg) with the following command
docker build . -t webimg
8. Once the image is built successfully then create a container with this image with port forwarding of port number 80.
docker container run -it --name web -p 80:80 -d webimg
9. On the browser with the public IP address of the ubuntu VM you can see the output of the application.
10. Push the docker image to the container registry with the following commands (myreg101.azurecr.io is the azure container registry server in my case)
docker login myreg101.azurecr.io
docker image tag webimg myreg101.azurecr.io/mynginx
docker push myreg101.azurecr.io/webimg
11. In VS project add a Docker file
12. Create an Azure Pipeline with above project and add below pipeline
13.Run the pipeline and a docker image should be created in Azure container registry.
14. Create a release pipeline for docker container.
In the Agent job Use Azure CLI and write an Inline script
az container create -g MyRG --name appinstance200130 --cpu 1 --memory 1 --port 80 --ip-address Public --image myreg101.azurecr.io/mynginx --registry-username myreg101 --registry-password waJ3dncLQE4jDLolaa9hVvUmeoSMwIS/
15. Container instance should be created
COMMENTS