Deploy docker compose on Azure Container App - azure

from ACA docs we have to specify target port of the container
az containerapp create \
--name my-container-app \
--resource-group $RESOURCE_GROUP \
--environment $CONTAINERAPPS_ENVIRONMENT \
--image mcr.microsoft.com/azuredocs/containerapps-helloworld:latest \
--target-port 80 \
--ingress 'external' \
--query configuration.ingress.fqdn
Now my question is how to deploy via docker-compose not just a single image, since there is a single target-port?

If you want to deploy multiple containers to a single container app, you can define more than one container in the configuration's containers array
Reference: Containers in Azure Container Apps Preview | Microsoft Docs
Alternative
If you want to deploy your application via Docker Compose, you can deploy to Azure Web app
While creating the web app, select publish as Docker Container. Under Docker, select options as Docker Compose and provide the Docker Compose file

Related

Azure VM/Docker – How to deploy website as Docker Container on Azure VM (Debian)

I am trying to deploy simple website as Docker Conteiner on Azure Virtual Machine port 80.
Procedure:
1 – Create VM and open port 80:
az group create --name my-vm-rg --location germanywestcentral
az vm create --resource-group my-vm-rg --name linuxVM --image Debian --admin-username <admin_user> --admin-password <admin_password> --authentication-type password --public-ip-sku Standard --size Standard_B1ms --disable-integrity-monitoring
az vm open-port --resource-group my-vm-rg --name linuxVM --port 80
2 – Connect to VM using Putty and install Docker, nano, update machine etc.
3 – Create new folder and simple index.html with <h1>Hello World</h1>
4 – Create Dockerfile
FROM nginx:1.17.1-alpine
LABEL maintainer="Name Surname <email>" description="Some random description"
COPY . /usr/share/nginx/html
5 – Build Dockerfile:
docker build -t docker-test-img .
docker image ls -a
docker run --name my-app -d -p 8080:80 docker-test-img
docker container ls -a
QUESTION: Docker container is running, but I can not access website from my local computer browser using <machine_ip_address>:80 or <machine_ip_address>:8080. I am getting „This site can’t be reached” error.
Why do I need it? I am trying to learn something new and yes, it has to be Azure VM. OS can be different.
Since you're opening port 80 in your VM, you should run your container using -p 80:80 instead.

How to Deploy local Docker image to Azure app services?

Created Azure app services web app without using any Docker registry integration.
I want achieve below.
1] create, tag image on my Linux machine
2] deploy local Docker image to App services web app using below
az webapp config container set --name springboot-docker-helloworld-app --resource-group SpringBoot --docker-custom-image-name org/dockerspringtboot-metinv:latest
But it is not working.
Is it possible to deploy local Docker images to Azure app services web app ?
You'll need to push your container image to an Azure container registry from which your Azure web app can pull the image.
You can do this using Azure CLI with the following steps:
$ az acr create --resource-group your_rg \
--name yourAcrName --sku Basic
# login to the container registry locally
$ az acr login --name yourAcrName
# update the container registry to use admin-enabled
# https://learn.microsoft.com/en-us/azure/container-registry/container-registry-authentication?tabs=azure-cli#admin-account
$ az acr update -n yourAcrName --admin-enabled true
# tag your local image to the container registry
$ docker tag dockerspringtboot-metinv:latest yourAcrName/dockerspringtboot-metinv:latest
# push image to your container registry
$ docker push yourAcrName/dockerspringtboot-metinv:latest
Then you can create an app service plan and deploy the web app specifying to use your container registry.
$ az appservice plan create -g your-rg \
-n your-app-plan \
--sku B1 --is-linux
# deploy your container as an app in the created App Service plan
$ az webapp create -g your-rg \
-p your-app-plan \
-n dockerspringtboot \
-i yourAcrName/dockerspringtboot-metinv:latest

How to activate settings in the web app when deployed as deployment-container-image-name

I have deployed a "Container Image" on to Web App Service with the following command.
az webapp create --name Dev-App --plan Dev-AppServicePlan \
--resource-group Dev \
--deployment-container-image-name ...devcontainerregistry.azurecr.io/app-node:latest
After the app was successfully deploment I need to change some Environment variables via the following commands.
az webapp config appsettings set --name Dev-App --resource-group Dev \
--settings MONGO_DSN='mongodb://cosmosdb...'
az webapp config appsettings set --name Dev-App --resource-group Dev \
--settings REDIS_URI='...dev.redis.cache.windows.net:6380...'
az webapp log config --name Dev-App --resource-group Dev \
--docker-container-logging filesystem
Now I have updated and restarted the Web App but it looks like the Image is not redeployed or at least the Environment variables are not there.
az webapp update --name Dev-App --resource-group Dev
az webapp restart --name Dev-App --resource-group Dev
I looked with log tail to the logs but the logs are also not changed. What I mean with "not changed" is that the log output is stucked to the Timestamp "2021-01-13T13:21:31.100Z" even when I restart the Web App.
az webapp log tail --name Dev-App --resource-group Dev
In this Articles from MS is described that a restart should be enough but then should also the log output should be changed.
2: Redeploy a container to Azure App Service after making changes
Configure a custom container for Azure App Service
Any hint how to activate the new settings in the custom image setup or trigger a redeployment?
FYI: I have also created a question in the azure community.
https://learn.microsoft.com/en-us/answers/questions/230584/how-to-activate-settings-in-the-web-app-when-deplo.html
It seems you want to updates the environment variables just like add them in the command:
docker run --name container_name image -e env_var1 -e env_var2
The Azure CLI command just sets the environment variables for the Web App service, you can see them in the Kudu, but it's not the same result as the docker run command.
I recommend you use the docker-compose to deploy your image to the Web App service. Here is the example for the docker-compose. You can update the environment variables in the environment option of the docker-compose file in the portal. Then it will restart again and refresh the logs. And the variables you added will also take effect.
Well the solution for my problem was that I change the registry from "Private Registry" to "Azure Container Registry" in the "container settings" page after running the following command
az webapp create --name Dev-App \
--plan Dev-AppServicePlan \
--resource-group chat-Dev \
--deployment-container-image-name devcontainerregistry.azurecr.io/chat-node:latest
I have put the acr data into the fields and activated the "Continous Deployment"
After this change every settings change triggers a restart and the ENV Variables was in the new instance.

Connecting to a jenkins container running on azure

I'm currently running jenkins from a container on my azure container instances, but I'm having difficulty with connecting. I specified port 80 when I run the CLI command:
az container create -g MyResourceGroup --name MyName --image MyImage --ports 80
Is there something I missed or another way I could configure it from the portal so that I can connect and setup jenkins? Any help would be appreciated.
The possible reason is that your container instance is not accessible outside because you do not expose it to the Internet. If you want to expose it to the Internet, the command should be like this:
az container create -g MyResourceGroup --name MyName --image MyImage --ports 80 --ip-address Public
For more details, see parameter --ip-address in az container create.
Or you can connect into the container instance through the CLI command az container exec -g MyResourceGroup --name mynginx --container-name nginx --exec-command "/bin/bash" or exec the command in the portal.
In addition, it seems you run Jenkins in the container instance. I would not recommend you do this. Because the Container Instance is a light-weight service, if you run a server in it, then it won't be actually what it should be anymore. The VM is an appropriate host for the Jenkins server. See Jenkins in VM.
Did you specify the DNS name with the parameter --dns-name-label

Deploy image from docker hub to AZure

I want to deploy a image from docker hub to Azure Container Instance.How can we do this.Is it mandatory to push the image first to Azure Container Registry?
All solutions I am getting shows that we need to push the image first to Azure Container Registry.
No, you need not push the image to ACR first, just let the image stay in the docker hub. For example, deploy the Nginx docker image to ACI, the Azure CLI command like below:
az container create -g resourceGroup -n aciName --image nginx --ports 80
As the command shows, you can use the docker image. Actually, the docker hub is the default registry. When you use another registry, you need to add the parameters --registry-login-server, --registry-username and --registry-password. For more details, see az container create.
It also shows clearly in the Azure portal, when you create ACI in the portal, you can see it like below:
You can use docker image directly with the container as follows,
az container create --resource-group myResourceGroup --name mycontainer --image docker image url

Resources