In Docker Compose, the volume configuration is slightly different from Kubernetes. The volumeMounts
syntax you used seems to be more in line with Kubernetes. In Docker Compose, you should define your volumes under the volumes
section of a service and then define the volume details at the bottom of the file.
version: "3.6"
services:
postgres:
image: postgres:15
volumes:
- filesharevolume:/var/lib/postgresql/data
restart: always
# ... other services ...
# Define your other services here
volumes:
filesharevolume:
driver: azure_file
driver_opts:
share_name: sharedfolder
storage_account_name: leostorageaccount2
storage_account_key: uyQcwH+b0dwK...v+2NKOLI+AStOTglYw==
Make sure that the Azure File Share (sharedfolder
) exists in your Azure Storage Account (leostorageaccount2
) and that the storage account key is correct. After making these changes, redeploy your services and verify that the data persists across container restarts.