Unable to create Azure App Service with Docker Compose and Mongodb - azure

I have Azure Container Registry
xxxxxxxx.azurecr.io
Inside of it I have 1 image
learning-docker01/api
Next, I create App Service. I select Docker Container as publish option and following options:
Options: - Docker Compose (Preview)
Image Source - Azure Container Registry
Registry - xxxxxxxx
Next I select my docker-compose.yaml file. The configuration looks like this:
version: "3.4"
services:
docker001.api:
image: xxxxxxxx.azurecr.io/learning-docker01/api
build:
context: ./Docker001.API
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://+:80
ports:
- "8000:80"
mongo:
image: mongo
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=root
- MONGO_INITDB_DATABASE=docker
ports:
- 27017:27017
Then I hit Review & Create and everything deploys smoothly.
The problem - after deployment, if I view Log Stream (Preview) I see the following Errors:
DockerApiException: Docker API responded with status code=InternalServerError,
response={"message":"Get https://registry-1.docker.io/v2/library/mongo/manifests/latest:
unauthorized: incorrect username or password"}
----
Pulling docker image mongo failed:
---
Container for learningdocker001_mongo_0_986c7f1a site learningdocker001 is unhealthy, Stopping site.
I'm not sure what the problem is. Everything runs fine locally. On Azure docker001.api service runs but mongo service doesn't.

You need to set up authentication to allow the App Service to pull images from the ACR.
Recommended way is to use the Managed Identity. Detailed setup description here: https://learn.microsoft.com/en-us/azure/app-service/tutorial-custom-container?pivots=container-linux#configure-app-service-to-deploy-the-image-from-the-registry

Related

multi-container app build via docker-compose in Azure Container Registry work locally but fail on Azure app services

I containerized an app that has two servers to run: rasa and action_server. I used docker-compose to build the images and then pushed them to Azure Registery Container.
I run the images locally from Azure Registry Container and works fine on localhost.
However, when I deployed the app on Azure App Services, the app restarts with an error.
2022-11-04T17:57:56.583Z ERROR - Start multi-container app failed
2022-11-04T17:57:56.593Z INFO - Stopping site demosite because it failed during startup.
2022-11-04T18:01:36.904Z INFO - Starting multi-container app..
2022-11-04T18:01:36.910Z ERROR - Exception in multi-container config parsing: Exception: System.InvalidCastException, Msg: Unable to cast object of type 'YamlDotNet.RepresentationModel.YamlScalarNode' to type 'YamlDotNet.RepresentationModel.YamlMappingNode'.
2022-11-04T18:01:36.911Z ERROR - Start multi-container app failed
2022-11-04T18:01:36.914Z INFO - Stopping site demosite because it failed during startup.
docker-compose.yaml
version: '3'
services:
rasa:
container_name: "rasa_server"
user: root
build:
context: .
volumes:
- "./:/app"
ports:
- "80:80"
action_server:
container_name: "action_server"
build:
context: actions
volumes:
- ./actions:/app/actions
- ./data:/app/data
ports:
- "5055:5055"
I tried to make another app but the problem remains.
As stated in the documentation, build is unsupported. You need to modify your compose file to reference the images stored in ACR.
Also, App Service only listens on port 80/443 so you can't expose your action_server on port 5055.

:( Application Error when trying to deploy docker-compose app in azure app service

I am trying to deploy a Django application on the azure app service using docker-compose, I already pushed two images to ACR and when I executed the docker-compose.yml on my computer everything worked fine, but when I deploy the app and visit the URL it only shows the next message:
":( Application Error
If you are the application administrator, you can access the diagnostic resources."
I also searched in the deployment center logs for any kind of info but there is only this message
"Failed to load container logs: Resource containerlog of type text not found"
any idea how can I fix it?
this is my docker-compose.yml
services:
web:
image: zaito.azurecr.io/backgroundtasks:latest
command: uwsgi --http "0.0.0.0:8000" --protocol uwsgi --module zaitoTasksApi.wsgi --master --processes 4 --threads 2
volumes:
- static_volume:/usr/src/app/static
- media_volume:/usr/src/app/media
expose:
- "8000"
nginx:
image: zaito.azurecr.io/nginx:django
restart: always
volumes:
- static_volume:/usr/src/app/static
- media_volume:/usr/src/app/media
ports:
- "80:80"
depends_on:
- web
volumes:
media_volume:
static_volume:

Deploying via Docker Compose to Azure App Service with multiple containers from different sources

I have a docker-compose.yml file which is created from a build step in Azure Devops. The build step works well and I can see how the docker-compose.yml file is produced. That makes sense to me.
However, it is looking for a normal docker image to run one of the services and the other service is one I've created and am hosting in my Azure Container Registry.
The docker compose file looks like this:
networks:
my-network:
external: true
name: my-network
services:
clamav:
image: mkodockx/docker-clamav#sha256:b90929eebf08b6c3c0e2104f3f6d558549612611f0be82c2c9b107f01c62a759
networks:
my-network: {}
ports:
- published: 3310
target: 3310
super-duper-service:
build:
context: .
dockerfile: super-duper-service/Dockerfile
image: xxxxxx.azurecr.io/superduperservice#sha256:ec3dd010ea02025c23b336dc7abeee17725a3b219e303d73768c2145de710432
networks:
my-network: {}
ports:
- published: 80
target: 80
- published: 443
target: 443
version: '3.4'
When I put this into an Azure App Service using the Docker Compose tab, I have to select an image tab - either Azure Container Registry or Docker Hub - I'm guessing the former because I am connected to that.
When I start the service, my logs say:
2020-12-04T14:11:38.175Z ERROR - Start multi-container app failed
2020-12-04T14:23:28.531Z INFO - Starting multi-container app..
2020-12-04T14:23:28.531Z ERROR - Exception in multi-container config parsing: Exception: System.NullReferenceException, Msg: Object reference not set to an instance of an object.
2020-12-04T14:23:28.532Z ERROR - Start multi-container app failed
2020-12-04T14:23:28.534Z INFO - Stopping site ingeniuus-antivirus because it failed during startup.
It's not very helpful, and I don't think there's anything wrong with that docker-compose.yml file.
If I try to deploy ONLY the service from the Azure Container registry, it deploys, but doesn't deploy the other service.
Does anyone know why the service doesn't start?
Well, there are two problems I find in your docker-compose file for the Azure Web App.
One problem is that Azure Web App only supports configuring one image repository in the docker-compose file. It means you only can configure the Docker Hub or ACR, not both.
Another problem is that Azure Web App does not support the build option in the docker-compose file. See the details here.
According to all the above, I suggest you can create all your custom images and push them to the ACR and use the ACR only.

I canĀ“t pull image from azure ACR

This is my first time using azure, I made a Pipeline in DevOps that creates images from dockerfile and pushes them to my ACR. Then I created a multi-container web app use docker-compose and connected my ACR to the web app. But the web app can't pull the images from the ACR. I don't know what I am doing wrong.
I am getting errors when I try to pull images from ACR in multi container web app.
Errors:
2019-11-28 19:27:46.755 INFO - Pulling image: [registry-name].azurecr.io/server
2019-11-28 19:27:46.921 ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"manifest for [registry-name].azurecr.io/server:latest not found: manifest unknown: manifest unknown"}
Docker-compose config:
version: "3"
services:
# SERVER CONTAINER
server:
image: [registry-name].azurecr.io/server
expose:
- 4000
ports:
- 4000:4000
command: node src/server.js
restart: always
# CLIENT CONTAINER
client:
image: [registry-name].azurecr.io/client
ports:
- "80:80"
- "443:443"
links:
- server
depends_on:
- server
restart: unless-stopped
First of all, the error shows that it cannot find the [registry-name].azurecr.io/server image with latest tag. So if your image does exist, then the problem is the tag.
If you do not add the tag for your image, it will pull the latest tag in default generally. The logs show like this:
But add a special tag for the image is better than no tag. If you want to get the latest image from the ACR, then always add the latest tag when push the image, do the same when you use that image.

VSTS push docker-compose to Azure Container Registry and WebApp

I would like to configure continuous integration from VSTS to Azure Container Registry and then to WebApp.
Here's my docker-compose.yml file:
As you can see I'm using an Asp.Net core + mssql.
version: '3'
services:
api:
image: tbacr.azurecr.io/myservice/api
container_name: api
build:
context: ./Api
dockerfile: Dockerfile
ports:
- "8000:80"
depends_on:
- db
db:
image: "microsoft/mssql-server-linux"
container_name: mssql
environment:
SA_PASSWORD: "testtest3030!"
ACCEPT_EULA: "Y"
MSSQL_PID: "Developer"
ports:
- "127.0.0.1:8001:1433"
Here's my task from VSTS:
And I think the major task is Build Services and PublishServices
So, please take a look below:
Build Services
PublishServices
And finally, in Azure Container Registry I have:
So, the question is how can I deploy it to the WebApp. I have tried right-click to api: latest repository and deploy to WebApp but the endpoint does not respond
There is 2 steps im VSTS : build and release. It seems your build part is ok. So your docker image is pushed in your repo. Then you have to configure the build part in VSTS that will get the image you just pushed on the repo and deploy it on a server.
HTH

Resources