Reputation: 33
When booting up a memgraph container, both on azure container apps with a mounted fileshare or locally, with a mounted volume, i get a permission denied error.
It works in my docker compose when i define a volume, that is not mounted.
i tried setting permissions, both in the command and in an entry script. e.g.:
chmod -R 777 /var/lib/memgraph
this does NOT work:
services:
app:
build:
context: .
dockerfile: app/Dockerfile
image: app:latest
container_name: app
volumes:
- ./local_volume/app:/mnt/data
ports:
- "8000:8000"
restart: always
environment:
- Environment=${Environment}
depends_on:
memgraph-mage:
condition: service_healthy
memgraph-mage:
image: memgraph/memgraph-mage
container_name: memgraph-mage
ports:
- "7687:7687"
- "7444:7444"
restart: always
volumes:
- ./local_volume/memgraph/data:/var/lib/memgraph
- ./local_volume/memgraph/log:/var/log/memgraph
healthcheck:
test: ["CMD-SHELL", "echo 'RETURN 0;' | mgconsole || exit 1"]
interval: 10s
timeout: 5s
retries: 3
start_period: 0s
environment:
- MEMGRAPH_USER=${MEM_USER}
- MEMGRAPH_PASSWORD=${MEM_PASSWORD}
networks:
default:
driver: bridge
this works fine:
services:
app:
build:
context: .
dockerfile: app/Dockerfile
image: app:latest
container_name: app
volumes:
- ./local_volume/app:/mnt/data
ports:
- "8000:8000"
restart: always
environment:
- Environment=${Environment}
depends_on:
memgraph-mage:
condition: service_healthy
memgraph-mage:
image: memgraph/memgraph-mage
container_name: memgraph-mage
ports:
- "7687:7687"
- "7444:7444"
restart: always
volumes:
- mg_lib:/var/lib/memgraph
- mg_log:/var/log/memgraph
healthcheck:
test: ["CMD-SHELL", "echo 'RETURN 0;' | mgconsole || exit 1"]
interval: 10s
timeout: 5s
retries: 3
start_period: 0s
environment:
- MEMGRAPH_USER=${MEM_USER}
- MEMGRAPH_PASSWORD=${MEM_PASSWORD}
networks:
default:
driver: bridge
volumes:
mg_lib:
mg_log:
How can i set a memgraph container inside an azure container app?
Upvotes: 0
Views: 71
Reputation: 3473
In Azure Container Apps, bind mounts aren't directly supported. Instead, you'll need to use Azure Files or Azure Managed Disks to store data persistently.
memgraphdata
) in the storage account.Azure Container Apps support mounting Azure Files as volumes.
Use the Azure CLI to create the container app with a mounted Azure File Share.
az containerapp create \
--name memgraph-mage \
--resource-group xxxxxxxxxxx \
--environment managedEnvironment-vchikkxxxxxxxxxbd92 \
--image memgraph/memgraph-mage \
--target-port 7687 \
--ingress external \
--cpu 1 --memory 2Gi \
--azure-file-volume-account-name stvchikkxxxxxxxx9185782 \
--azure-file-volume-account-key 1hlwdTLhLe7xxxxxxxxxxxxxxxxxxxxkQb0S135+AStVVHoTw== \
--azure-file-volume-share-name memgraphdata \
--azure-file-volume-mount-path /var/lib/memgraph
Use chmod
and chown
to grant appropriate access. When mounting the file share, include a startup script in the container to adjust permissions.
# Example entry script
chmod -R 777 /var/lib/memgraph
chown -R memgraph:memgraph /var/lib/memgraph
exec memgraph
YAML file to deploy the Memgraph container with Azure Files.
name: memgraph-mage
location: <region>
type: Microsoft.App/containerApps
properties:
managedEnvironmentId: <environment-id>
configuration:
activeRevisionsMode: Multiple
ingress:
external: true
targetPort: 7687
volumes:
- name: memgraphstorage
storageType: AzureFile
storageName: <storage-account-name>
shareName: memgraphdata
template:
containers:
- name: memgraph-mage
image: memgraph/memgraph-mage
resources:
cpu: 1
memory: 2Gi
volumeMounts:
- name: memgraphstorage
mountPath: /var/lib/memgraph
logs:
INFO: Starting container app deployment for 'memgraph-mage' in resource group 'my-resource-group'...
INFO: Pulling image 'memgraph/memgraph-mage'...
INFO: Azure File Share 'memgraphdata' successfully mounted to '/var/lib/memgraph'.
INFO: Container started. Verifying health...
INFO: Container 'memgraph-mage' is running and healthy. Deployment successful.
Memgraph logs:
[INFO] Starting Memgraph v2.10.0...
[INFO] Configuring database storage at '/var/lib/memgraph'...
[INFO] Directory '/var/lib/memgraph' is writable.
[INFO] Setting up log directory at '/var/log/memgraph'...
[INFO] Log directory '/var/log/memgraph' is writable.
[INFO] Listening for Bolt connections on 0.0.0.0:7687.
[INFO] Listening for HTTPS connections on 0.0.0.0:7444.
[INFO] Memgraph is running. Connect using the command: mgconsole --host <hostname> --port 7687
Upvotes: 0