Venkata Dorisala
Venkata Dorisala

Reputation: 5075

Deploy a docker container on Azure App Service Linux

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:

Upvotes: 1

Views: 3564

Answers (3)

Gaurav Kumar
Gaurav Kumar

Reputation: 156

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

enter image description here

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

File Storage

enter image description here

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

enter image description here

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

Upvotes: 0

helge
helge

Reputation: 21

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://learn.microsoft.com/en-us/azure/app-service/containers/app-service-linux-faq#custom-containers

Upvotes: 2

Charles Xu
Charles Xu

Reputation: 31452

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.

Upvotes: 1

Related Questions