Search code examples
azuredockerazure-web-app-servicedocker-volumemetabase

Deploy Metabase in Azure App Service with Docker and File Share


I want to deploy Metabase in Azure App Service through a Docker container. I did push my image to ACI and publish it into an Azure App Service. Metabase works well with the default configuration.

However, I would like to store the H2 db files into a File Share in order to keep my configuration (dashboard, questions, everything related to Metabase etc.) in a persistent storage.

I am following this documentation: https://www.metabase.com/docs/latest/operations-guide/running-metabase-on-docker.html

In my Azure app service, I added a File Share: enter image description here

Then I added the following command into my App Service -> Configuration -> General settings -> Startup Command -> -v ~/utpmv-fs-analytics:/utpmv-fs-analytics -e "MB_DB_FILE=/utpmv-fs-analytics/metabase.db" enter image description here

I have tried many commands but I always get something like:

    ...
    2020-12-09T21:54:26.166Z INFO  - Pull Image successful, Time taken: 0 Minutes and 0 Seconds
    2020-12-09T21:54:26.210Z INFO  - Starting container for site
    2020-12-09T21:54:26.211Z INFO  - docker run -d -p 4569:3000 --name utpmv-as-analytics_0_ad156b06 -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=true -e WEBSITE_SITE_NAME=utpmv-as-analytics -e WEBSITE_AUTH_ENABLED=False -e PORT=3000 -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=utpmv-as-analytics.azurewebsites.net -e WEBSITE_INSTANCE_ID=23939ad800d68063d3342e54a06273dd0c500ce73e1a03d19d89f03a71039aab utpmvcranalytics.azurecr.io/metabase:v1 -v ~/utpmv-fs-analytics:/utpmv-fs-analytics -e "MB_DB_FILE=/utpmv-fs-analytics/metabase.db"
    2020-12-09T21:54:26.211Z INFO  - Logging is not enabled for this container.Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
    2020-12-09T21:54:29.007Z INFO  - Initiating warmup request to container utpmv-as-analytics_0_ad156b06 for site utpmv-as-analytics
    2020-12-09T21:54:36.717574375Z su: unrecognized option: e
    2020-12-09T21:54:36.720173722Z BusyBox v1.31.1 () multi-call binary.
    ...

It looks like the -v command is not recognized which seems very weird. I wonder if I am adding the command to the correct place in my Azure App Service.

Do you guys have any idea?

Thank you very much!


Solution

  • First of all, you need to know what does the "Startup command" means. It means a command needs to execute inside the container at the start time. And it will cover the command in the Dockerfile of the image for CMD. It does not work as you expected like:

    docker run -v -v ~/utpmv-fs-analytics:/utpmv-fs-analytics -e "MB_DB_FILE=/utpmv-fs-analytics/metabase.db" utpmvcranalytics.azurecr.io/metabase:v1
    

    I think you want to mount the file share and then set the environment variable MB_DB_file for the DB storage path. For this purpose, you can set the environment variable in the Dockerfile and then mount the file share in the Azure portal. Or you can use the docker-compose file to set the environment variable and mount the file share. Here is the example for the docker-compose. I more recommend the docker-compose file.