I tried to deploy multiple containers to Azure Container Instances with docker compose file. My containers contain one server container and one postgressql db container. The server container is able to start up but the db container fail to start up (But I can't find any error message from the command line or on Azure)
The docker compose file is able to run locally, the only change I have made is on the "volumes:" part (last part of my docker compose yaml file) to mount the azure file share to the container for persistent storage and store some SQL scripts (in the sql file share) that will run when the database initialize (is this possible on Azure?).
I have already created the two file shares in my storage account
I am not sure if this mounting/running SQL during initialization is possible on Azure Container Instances.
Below is my yaml file
services:
server:
build:
context: ./backend
dockerfile: Dockerfile
image: <my azure container registry>.azurecr.io/<my image name>
# volumes:
# - ./app/:/code/app/
command: uvicorn app.main:app --reload --workers 1 --host 0.0.0.0 --port 8000
ports:
- 8000:8000
environment:
<some environment variable here>
depends_on:
- db
db:
image: postgres:13-alpine
volumes:
- postgres-data:/var/lib/postgresql/data/
- sql:/docker-entrypoint-initdb.d # Azure
# - ./sql:/docker-entrypoint-initdb.d # local
environment:
<some environment variable here>
ports:
- 5432:5432
volumes:
postgres-data:
driver: azure_file
driver_opts:
share_name: postgres-data
storage_account_name: <my storage account>
storage_account_key: <my storage account access key>
sql:
driver: azure_file
driver_opts:
share_name: sql
storage_account_name: <my storage account>
storage_account_key: <my storage account access key>

