Deploy a docker container on Azure App Service Linux

azure web app for containers tutorial
azure app service docker port
azure app service docker compose
azure web app container environment variables
azure app service vs docker
azure container registry
azure docker
azure app service windows containers

I have a simple app built as docker image (ubuntu) and put it into docker container. It has few volumes attached to it. I want to push this container to Azure AppService Linux. I tried a few options but with no success.

  1. Azure CLI to create a web app and push container to azure container registry and then deploy that to web app.

    Gives invalid reference format error.

  2. Uploaded container to acr and updated web app container settings to load this container into web app.

    Gives image not found or invalid reference format errors.

Not sure how to proceed on this. Any help is highly appreciated. I would also like to know how to use persistent storage for volumes here. Azure fileshare is better option but not sure how to map that to container path.

Below is my sample docker-compose file.

version: "3.3"
services:
  test-backend:
    image: test-002
    container_name: test-002
    restart: always
    volumes:
     - ./assets:/opt/test_files
     - ./medialibrary:/opt/test_medialibrary
     - ./app-configs:/opt/test_configs
     - ./logs/backend:/opt/test-backend-logs
    extra_hosts:
     test-converter: "127.0.0.1"
    ports:
     - "8000:8000"
volumes:
  test-data:
  test-data2:

With the destination you describe above, first you should run the image locally to check if the it is work well. You should check if the image related in the compose file is there in your local machine.

If you want to push your image to Azure Container Registry and deploy the web app from the image. You can get more details for the steps from Use a custom Docker image for Web App for Containers.

In my opinion, I suggest if you just have one service to deploy you can use the Dockerfile instead of docker compose file. It's more simple to deploy no matter the the docker image or Azure Web App service. And the docker compose is more helpful for multi services.

Quickstart: Run a custom Linux container, App Service provides built-in Docker images on Linux with support for specific Deploy a custom image to a private container registry; Run the  Deploy the image to Azure App Service. Now that everything is configured, you can deploy your image to Azure App Service directly from the Docker extension explorer. Find the image under the Registries node in the DOCKER explorer, and expand it to show its tags. Right-click a tag and then select Deploy Image to Azure App Service.

The image reference has to be in the format: image: server-name.azurecr.io/image-name:tag

Other than that I recommend this FAQ which helped me a lot in getting my application up and running: https://docs.microsoft.com/en-us/azure/app-service/containers/app-service-linux-faq#custom-containers

Tutorial: Build and run a custom image, Discover how to create a Docker image and store it in the Azure Container Registry, then use Azure App Service to deploy a web application based on the  Quickly and easily migrate your apps to Azure to increase security and modernize app services. With Docker deployment on Azure, you’re able to run modern and traditional Linux or Windows apps with enterprise-grade security, support, and scale. Get integrated management, security, and cost savings. Drive down operational costs and improve

Here’s how you can mount Azure Storage to your multi-container WebApp (using docker-compose.yml):

#Sample Docker Compose:
version: '3.3'

services:
   web:
     image: appsvc/python
     ports:
       - "8000:8000"
     volumes:
       - test:/home/site/wwwroot/test

volume:
     - test
Path Mapping

("test" is the custom-id which we have used in the docker-compose.yml)

File Storage

We can now see the directories present in the storage from the webapp container:

https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/app-service/containers/how-to-serve-content-from-azure-storage.md

Deploy and run a containerized web app with Azure App Service , Push the image to a container registry. Deploy the image to Azure App Service. Prerequisites#. An Azure subscription. Docker and Azure App  If you want to push your image to Azure Container Registry and deploy the web app from the image. You can get more details for the steps from Use a custom Docker image for Web App for Containers. In my opinion, I suggest if you just have one service to deploy you can use the Dockerfile instead of docker compose file.

Deploying a Docker based web application to Azure App Service , At this point your .Net Core Web Application is running in a Linux Docker Container, on Azure App Service! Azure App Service Deploy will pull the appropriate docker image corresponding to the BuildID from repository specified, and then deploys the image to the Linux App Service.

Deploy a containerized app to Azure App Service, Now let's get back to Azure… Under the “All Services” tab search using the keyword “docker” and choose “App Services”. Now click on “+ Add” Operating system: Choose “Linux”. Location:  Just pull container images from Docker Hub or a private Azure Container Registry, and Web App for Containers will deploy the containerized app with your preferred dependencies to production in seconds. The platform automatically takes care of OS patching, capacity provisioning, and load balancing.

Deploying Docker Containers to Azure App Service, To deploy the eShopOnWeb sample to a Linux Docker container on Azure App Services from Visual Studio, follow these step-by-step  It has never been easier to deploy container-based web apps. Just pull container images from Docker Hub or a private Azure Container Registry and Web App for Containers will deploy the containerised app with your preferred dependencies to production in seconds.

Comments
  • I am looking for solution in app service for web containers. Container instance on it's own doesn't scale and suitable for short jobs.
  • Do you have seen multi-container app? This is just preview version.
  • I have seen that but mounting volumes is the problem.
  • Could you set the environment variable WEBSITES_ENABLE_APP_SERVICE_STORAGE? You can take a look at this.
  • Thanks. But any idea how to mount volumes to azure app service ? i prefer to use file share. is it possible ?
  • unfortunately, it seem you cannot mount volume to azure app service. As I know you can mount volumes in ACI or AKS. You also can deploy the app to them.
  • ACI ? you mean ACS?
  • I mean Azure Container Instance. See Azure Container Instances.