Back in May at Microsoft Build, we announced the public preview of Multi-Container Web App, which supports the ability for you to deploy multiple Docker images to Web App for Containers. All you have to do is bring your Docker Compose or Kubernetes Config file when creating a new web app. (Here are instructions to get started with
Multi-Container Web App).
Since we launched public preview, one of the most frequently asked questions that we've received is: "How do I configure Azure Container Registry with Multi-Container?"
Let me walk you through a quick tutorial that uses Azure Container Registry with Multi-Container.
Configure Your Docker Compose/Kubernetes File
To create a Multi-Container web app, you first need a Docker Compose or Kubernetes Config yml file. This is basically a definition file that describes a Multi-Container web app. Because we will be using Azure Container Registry (ACR), notice that the Docker Compose file has the ACR image repos in the file. The image with "ports: - 80:80" is the main container that exposed to Internet.
Here is a sample Docker Compose file:
version: '3'
services:
web:
image: [azure-container-registry-name].azurecr.io/flaskapp
ports:
– 80:80
redis:
image: [azure-container-registry-name].azurecr.io/redis:alpine
If this Docker Compose file looks familiar, it is
actually the same as the Docker Compose file in the Quickstart that you can use when creating a Multi-Container app (with DockerHub), with the exception of the ACR modifications.
Adding the App Settings
After you uploaded your Docker Compose file and clicked create, you will have to make sure App Service can access Azure Container Registry by adding the following App settings in the App Service portal:
DOCKER_REGISTRY_SERVER_USERNAME = [azure-container-registry-name]
DOCKER_REGISTRY_SERVER_URL = [azure-container-registry-name].azurecr.io
DOCKER_REGISTRY_SERVER_PASSWORD = [password]
Note: please make sure to enable admin access in the Azure Container Registry Server settings.
Limitations
All Docker images in the same Docker Compose or Kubernetes Config yml file
need to come from the same Azure Container Registry server. This means that you may have to pull down popular images (such as nginx and Redis) from DockerHub, and tag it for ACR then push to your ACR registry server.
Further limitations on Docker Compose/Kube Config configuration options are documented
here.
Checking Your Logs
After the web app is restarted, you should see logs similar to the ones below in Container settings or in Kudu. (Kudu is where you can view all your Docker logs and is your source control management site. Kudu can be accessed via [your web app name].SCM.azurewebsites.net or under "Advanced Tools" in the left-hand menu).
2018-06-19 19:26:33.419 ERROR – multi-container unit was not started successfully
2018-06-19 19:26:33.422 INFO – Container logs from yili-multicontainer-acr-01_web_0 =
2018-06-19 19:29:42.691 INFO – Starting multi-container app, configuration =
version: '3'
services:
# this image repo’s source come from “Get started with Docker Compose” on docker.com
web:
image: [azure-container-registry-name].azurecr.io/flaskapp
ports:
– 80:80
redis:
image: [azure-container-registry-name].azurecr.io/redis:alpine
2018-06-19 19:30:14.621 INFO – Starting container for site
2018-06-19 19:30:14.622 INFO – docker run -d -p 55955:80 –name yili-multicontainer-acr-01_web_0 -e WEBSITE_SITE_NAME=yili-multicontainer-acr-01 -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_INSTANCE_ID=6cc2f742b7330fbd63a5e79967ed9ee7904bb9d93c7ca7843312788a4c2bc622 yiliacr05.azurecr.io/flaskapp
2018-06-19 19:30:14.622 INFO – Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2018-06-19 19:30:22.542 INFO – Starting container for site
2018-06-19 19:30:22.543 INFO – docker run -d -p 0:6379 –name yili-multicontainer-acr-01_redis_0 -e WEBSITE_SITE_NAME=yili-multicontainer-acr-01 -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_INSTANCE_ID=6cc2f742b7330fbd63a5e79967ed9ee7904bb9d93c7ca7843312788a4c2bc622 yiliacr05.azurecr.io/redis:alpine
2018-06-19 19:30:22.544 INFO – Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2018-06-19 19:30:30.750 INFO – Started multi-container app
2018-06-19 19:30:30.778 INFO – Container yili-multicontainer-acr-01_web_0 for site yili-multicontainer-acr-01 initialized successfully.