Within an Azure App Service under an App Service Environment, I have configured a Docker Compose setup using the public Docker Hub as a registry source.
version: '3.7'
services:
web:
image: nginx:stable
restart: always
ports:
- '80:80'
Unfortunately this fails to deploy, and checking the logs, I see very little output:
2021-10-21T19:14:55.647Z INFO - Stopping site XXXX-as__6e65 because it failed during startup.
2021-10-21T19:15:02.054Z INFO - Stopping site XXXX-as__6e65 because it failed during startup.
2021-10-21T19:15:11.990Z INFO - Stopping site XXXX-as__6e65 because it failed during startup.
2021-10-21T19:15:28.110Z INFO - Stopping site XXXX-as__6e65 because it failed during startup.
2021-10-21T19:17:39.825Z INFO - Stopping site XXXX-as__6e65 because it failed during startup.
I'll note that moving to a single container setup (instead of a Docker Compose setup) works fine.
Below are few composing files to setup:
services:
web:
image: nginx
deploy:
restart_policy:
condition: on-failure
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80"]
interval: 10s
You can also deploy and manage multi-container applications defined in Compose files to ACI using the docker compose command. All containers in the same Compose application are started in the same container group. Service discovery between the containers works using the service name specified in the Compose file. Name resolution between containers is achieved by writing service names in the /etc/hosts file that is shared automatically by all containers in the container group.
We have a good blog related to this, please refer to it, thanks to docs.dockers.
I had a similar problem, but with error: "Container logs could not be loaded: Containerlog resource of type text not found".
The strange thing is that deploying it as a Single Container type (instead of a Docker Compose type) it works fine.
Also, exactly the same docker-compose works perfectly if you use normal App Service (without Environment).
So I suspect it is an Azure bug.
P.s. https://learn.microsoft.com/en-us/answers/questions/955528/-application-error-when-using-docker-compose.html
Related
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.
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 have an rshiny server setup in a docker container, and am trying to deploy this as an azure multi-container web app with some other services. I've already succeeded in deploying it in the single-container setting, for which I set the WEBSITES_PORT app setting to be 3838.
In my attempt to move to the multi-container situation, using the following docker-compose script:
version: '3.7'
services:
shiny-app:
image: my-shiny-image
restart: always
ports:
- "80:3838"
My understanding is that the 80-3838 mapping is what "informs" azure of what the website port is? This does not work when deployed, and I cannot retrieve any docker logs. I get the error message "Error retrieving logs". If I run the
az webapp log tail
command, it just hangs and then fails.
What am I doing wrong?
I deploy a container to a Service Fabric cluster (both Windows) in isolation with a docker-compose.yml like:
version: '3'
services:
webhost:
image: xxxxxcr.azurecr.io/container.image:latest
isolation: hyperv
deploy:
replicas: 2
ports:
- 80/http
environment:
...
But this container is not able to resolve DNS. When executing a nslookup inside the container it shows:
C:\>nslookup xxxxxdatabase.documents.azure.com
Server: UnKnown
Address: 172.31.240.1
*** UnKnown can't find xxxxxdatabase.documents.azure.com: Server failed
Deploying exactly the same image without isolation: hyperv does not cause into this problem.
I tried - without success - to add dns entries to the compose file as described in this answer. As it seems the dns may not be supported for Service Fabric compose.
More details:
nodes have this VM image: WindowsServerSemiAnnual / Datacenter-Core-1803-with-Containers-smalldisk / 1803.0.20190115
base image is: microsoft/dotnet:2.2-aspnetcore-runtime-nanoserver-1803
What do I need to do to get DNS resolution in this isolated container?
I am under a weird dilemma. I have created a node application and this application needs to connect to MongoDB (through docker container) I created a docker-compose file as follows:
version: "3"
services:
mongo:
image: mongo
expose:
- 27017
volumes:
- ./data/db:/data/db
my-node:
image: "<MY_IMAGE_PATH>:latest"
deploy:
replicas: 1
restart_policy:
condition: on-failure
working_dir: /opt/app
ports:
- "2000:2000"
volumes:
- ./mod:/usr/app
networks:
- webnet
command: "node app.js"
networks:
webnet:
I am using mongo official image. I have ommited my docker image from the above configuration .I have set up with many configuration but i am unable to connect to mongoDB (yes i have changed the MongoDB uri inside the node.js application too). but whenever i am deploying my docker-compose my application on start up gives me always MongoNetworkError of TransientTransactionError. I am unable to understand where is the problem since many hours.
One more weird thing is when i running my docker-compose file i receive following logs:
Creating network server_default
Creating network server_webnet
Creating service server_mongo
Creating service server_feed-grabber
Could it be that both services are in a different network? If yes then how to fix that?
Other Info:
In node.js application MongoDB uri that i tried is
mongodb://mongo:27017/MyDB
I am running my docker-compose with the command: docker stack deploy -c docker-compose.yml server
My node.js image is Ubuntu 18
Anyone can help me with this?
Ok So i have tried few things and i figured out at last after spending many many hours. There were two things i was doing wrong and they were hitting me on last point:
First thing logging of the startup of docker showed me that it was creating two networks server_default and server_webnet this is the first mistake. Both containers should be in the same network while working.
The second thing I needed to run the Mongo container first as my Node.js application depend_on the Mongo container to be run first. This is exactly what I did in my docker-compose configuration by introducing depend_on property.
For me it was:
1- get your ip by running command
docker-machine ip
2- don't go to localhost/port, go to your ip/port, example : http://192.168.99.100:8080