1

Maybe I do not understand the concept of Azure Container Instances (ACI) and Azure at all correctly. I am using Azure CLI on my Windows-Computer and want to create a Windows-container (core-image) with dockerfile. But there is no AZ command available. I am able to create a container, there is no problem. But not with a dockerfile. Is there a possibility to run docker commands for Azure (Azure CLI, Azure bash, Azure powershell)? Maybe somebody can clarify my misunderstanding. Many thanks in advance, J.

1
  • Any more questions? Does it solve your problem? I didn't see any updates. Commented Nov 18, 2019 at 9:32

3 Answers 3

2

Of curse, yes, you can use the Azure CLI command to build containers with Dockerfile. But there is a queue for the steps.

The docker image is the first step, you can use the CLI command az acr build to build the image directly in the ACR, with your Dockerfile. For example, the Dockerfile is in your local machine and it's windows image:

az acr build -t sample/hello-world:{{.Run.ID}} -r MyRegistry . --platform windows

The ACI is the second step, CLI command az container create will help you to create the container instance with your images. The example command here:

az container create -g MyResourceGroup --name mywinapp --image winappimage:latest --os-type Windows --cpu 2 --memory 3.5
Sign up to request clarification or add additional context in comments.

5 Comments

Thank you. Very helpful. I also learned that CLI-comands do not work in Azure Cloud Shell.
@Jefecito Well, if it solves your issue, please accept it as the answer.
@Jefecito I didn't know why you said my answer helpful but accept another one?
I can only accept 1 answer. Both were helpful. The other one was comprehensive and as a beginner I needed to understand and follow all steps.
@Jefecito I think my answer points out the key work of your problem which solves your problem. I don't think you achieve your requirements only follow the other answer.
0

Once you have your image, you should publish it to Azure Container Registry or Docker Hub.

Take a look on the following links, it provides the information to:

  • Create a container image for deployment to Azure Container Instances
  • Deploy the container from Azure Container Registry
  • Deploy your application

https://learn.microsoft.com/en-us/azure/container-instances/container-instances-tutorial-prepare-app

https://learn.microsoft.com/en-us/azure/container-instances/container-instances-tutorial-prepare-acr

https://learn.microsoft.com/en-us/azure/container-instances/container-instances-tutorial-deploy-app

1 Comment

Unfortunaltly I cannot rate your valuable answer. That's why I have to use the comment function. The links helped a lot.
0

I have recently done the same thing. I have deployed my windows service to Azure Container Instance through Azure Container Registry. Here is step by step process you need to follow. Before performing these steps you need to have published folder of application. You need to install Docker Desktop in your machine.

  1. Create Dockerfile with below commands and put it inside published folder:
 FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019  
 COPY . .
 ENTRYPOINT Application.exe
 Here you need to use base file as per your neeed. You can find Windows base images [here][1]
  1. Now navigate to this directory(published folder path) in Powershell and execute below command:
docker image build -t IMAGE_NAME:TAG .           -- name of the image with tag

docker run --rm IMAGE_NAME:TAG  -- you can run it locally

  1. Now to push this image to Azure, below are the commands. First login into azure and then azure container registery.
az login                   -- it will navigate to browser for login

docker login ACR_LOGIN_SERVER_NAME -u ACR_USERNAME --password ACR_PASSWORD

docker tag IMAGE_NAME:TAG ACR_LOGIN_SERVER_NAME/IMAGE_NAME:TAG  -- tag local image to azure inside ACR   

docker push ACR_LOGIN_SERVER_NAME/IMAGE_NAME:TAG -- push image to ACR
  1. Once you have pushed docker image to ACR, you can see it under Repositories in ACR. Based on this repository, you need to create Azure Container Instance to run your docker image.

  2. To create ACI, click on "Create a resource" and select Containers > Container Instances. Here, you need to key some info like resource group and docker image credentials. Make sure you select Private as Image type and key image registry credentials. This ACI deployment process may take couple of minutes as it will fetch the docker image and then deploy. Once deployment is done, you will see Container running and you can check logs as well.

Hope it helps!!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.