ACR build command not building Dockerfile - azure

I am trying to execute the following Azure CLI command targeting the Dockerfile in the root folder.
az acr build --registry <REGISTRY_NAME> --image myimage:latest .
And I get a '.' doesn't exist error.
Am I missing something basic here ?

Related

Deploy reactjs application on the container instance

I am very new to this Containers, so I am unable to deploy the application on the Container instance .
I tried below steps but i could not resolve the issue. Please help me out of this. Thanks in advance
steps:
1.I have created the Reactjs build.
2.Created the docker image and Create the container registry and pushed it into docker container instance.
my Docker file is :
FROM nginx: version
copy /build/user/share/nginx/html
I have created the docker image and build that image and successfully created the docker image
I have created the container rgistry and when I trying to push the docker image to container instance after that i am not able to access the application using web.
docker build -t image_name
Can anyone help me that how to access the application through UI
Thanks in Advance!
I tried to reproduce the same issue in my environment and got the below results
I have created and build the npm using below command
npm run build
I have created example docker file and run the file
#docker build -t image_name
FROM node:16.13.1-alpine as build
WORKDIR /app
ENV PATH /app/node/_modules/.bin:$PATH
COPY package.json ./
COPY package-lock.json ./
RUN npm install react-scripts -g --silent
COPY . ./
RUN npm run build
FROM nginx:stable-alpine
COPY --from=build /app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx","-g","daemon off"]
I have created the container registry
Enabled the access to to push the image to container registry
I have logged into the container registry using login server credentials
docker login server_name
username:XXXX
password:XXXXX
I have tagged and pushed the image into container registry
docker tag image_name login-server/image
docker push login-server/image_name
I have created the container instances to deploy the container image
While creating in Networking i have given the DNS label and created
By using FQDN link I can able to access the image through UI

az acr build dockerfile secret declaration

I am trying to pass secrets using build secret argument (values passed through github secrets) as mentioned in Microsoft documentation, how should I utilize these secrets in my dockerfile?
Currently I'm using ARG but looking at articles it isn't the best way.
Docker build:
az acr build -r $registry -f $resolvedDockerFilePath --platform $platform --image "$($Env:PROJECT_ENGAGEMENT):$($Env:DEPLOYMENT_VERSION)" --image "$($Env:PROJECT_ENGAGEMENT):latest" --secret-build-arg GITHUB_AUTH_TOKEN="$githubApiKey" --secret-build-arg LW_AGENT_TOKEN="$ENV:LW_AGENT_ACCESS_TOKEN" .
}
I've tried using ARG in dockerfile but it exposes the secrets in layers.Looking at similar posts most of them mention secret mounting from a file, but I'm not using any file to pass secrets.
How these secrets should be consumed inside dockerfile?

Az acr build command info needed

As per the documentation https://learn.microsoft.com/en-us/azure/container-registry/container-registry-quickstart-task-cli the below command builds and pushes to registry. What if I need only build and then push based on my interest .Because I have to scan image before pushing it.
az acr build --image sample/hello-world:v1
--registry myContainerRegistry008
--file Dockerfile .
Note: There is no docker daemon installed on the system.
As suggested in the Azure Documentation ,You can use --no-push flag in the az acr build command to build the docker file & not to push it to the registry,
Here is the sample output for reference :

Azure container registry repository or image delete giving error while executing using Azure CLI or Command Shell

Getting below error while deleting ACR repository or image.
Command: $ az acr repository delete --name pocacr2021 -repository repoNodeBulletin
Error: The requested data does not exist. Correlation Id:xxxx-xxxxx-xxxx-xxxxx
Error was coming due to passing repository name should be lower case. It won't allow upper or mixed case.
Wrong Command: $ az acr repository delete --name pocacr2021 -repository repoNodeBulletin
Correct Command: $ az acr repository delete --name pocacr2021 -repository reponodebulletin

Docker commands in Azure

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.
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
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
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.
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]
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
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
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.
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!!

Resources