Reputation: 151
Ok having a real issue here with Azure Web-app for multi-containers, no matter what I do, I can't get it to work. I've spend hours on this myself and also with Microsoft representatives.
The issue is that I can't get web-apps for multiple containers to work with my docker-compose file with related Docker images. The service is in "preview-mode" i.e. being some sorts of beta-version (my guess) so it may be some bug here at Microsoft's end, but I still wanted to write this post in hope that someone may have insight to help me figure this out.
This is the logs I'm getting when trying to access the application in the browser, and this is the only logs available, I have checked this with the Microsoft support:
2021-11-24T08:53:40.341Z INFO - Pull Image successful, Time taken: 0 Minutes and 0 Seconds
2021-11-24T08:53:40.357Z INFO - Starting container for site
2021-11-24T08:53:40.360Z INFO - docker run -d -p 9688:80 --name companybe_backend_0_df9f2437 -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITES_PORT=8000 -e WEBSITE_SITE_NAME=companybe -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=companybe.azurewebsites.net -e WEBSITE_INSTANCE_ID=*** -e HTTP_LOGGING_ENABLED=1 companycontainerregistry.azurecr.io/companybe:latest
2021-11-24T08:57:30.785Z ERROR - multi-container unit was not started successfully
2021-11-24T08:57:30.799Z INFO - Container logs from companybe_backend_0_df9f2437 = 2021-11-24T08:53:44.889298525Z projectile/manage.py:8: UserWarning: Not reading projectile/.env - it doesn't exist.
2021-11-24T08:53:44.889571929Z dotenv.read_dotenv()
2021-11-24T08:53:48.759572396Z projectile/manage.py:8: UserWarning: Not reading projectile/.env - it doesn't exist.
2021-11-24T08:53:48.759651597Z dotenv.read_dotenv()
2021-11-24T08:53:50.008743343Z Watching for file changes with StatReloader
2021-11-24T08:57:38.187Z INFO - Stopping site companybe because it failed during startup.
The line - Watching for file changes.... indicate that the service have started, as this is what I see when running it locally, and after that has appeared, I can access the service in the browser (when running locally).
However, for some reason, it seems like the web-app can't see that the service is running and it's being shut down (according to the logs and also that I can't get access to the service in the browser).
This is my docker-compose file which I supply trough the Azure-portal to the multi container app:
version: "3.3"
services:
backend:
image: companyregistry.azurecr.io/company:latest
container_name: backend
ports:
- "80:80"
I've here tried multiple configurations of the ports:
I've also tried adding/removing WEBSITES_PORT = 8000 and PORT=80 in the app-configuration.
To make sure that the image works, I've both tried running it locally, which works fine and in ACI (Azure Container Instances) which is also working as expected, where I can reach the service in the browser.
I have also tried following a tutorial with an Image provided by Azure and used this in the docker-compose supplied in Azure Portal, which work.
Furthermore I've also tried deploying it as a web-app for single containers, then using the Dockerfile (see below), which also work as expected (however then I need to have the WEBSITES_PORT and PORT configuration in place for it to work).
So I'm puzzled:
My Dockerfile:
# Set container as ubuntu
FROM ubuntu:20.04
# Workaround for making compose up to work as intended
ARG DEBIAN_FRONTEND=noninteractive
# Installing dependencies an packages
RUN apt-get update && apt-get install -y python3.9 python3.9-dev python3-pip postgresql-12 cron vim
RUN pip3 install psycopg2-binary
# Set workdir
WORKDIR /code
# Copy and install requirements
COPY requirements.txt /code/
RUN pip install -r requirements.txt
# Copy all files from project into Docker
COPY . /code/
EXPOSE 80
EXPOSE 8000
EXPOSE 8443
CMD python3 projectile/manage.py runserver 0.0.0.0:8000
Upvotes: 2
Views: 2533
Reputation: 151
Ok so after 4 days of working on this issue we finally found an answer. As the multi-container web-app is still in preview mode, it only accepts applications running on the default port 80. So the only thing that needed to be changed is to change the last line in the Dockerfile to:
CMD python3 projectile/manage.py runserver 0.0.0.0:80
Also the following line in the docker-compose file provided into the Deployment Center in the Azure Portal will not be honoured, thus being redundant and can be removed:
ports:
- "80:80"
So the new docker-compose is sufficient being:
services:
backend:
image: companyregistry.azurecr.io/company:latest
container_name: backend
Upvotes: 2