启动 memgraph 容器时,无论是在具有已安装文件共享的 Azure 容器应用程序上还是在本地具有已安装卷的情况下,我都会收到权限被拒绝的错误。
当我定义一个未安装的卷时,它可以在我的 docker compose 中工作。
我尝试在命令和入口脚本中设置权限。例如:
chmod -R 777 /var/lib/memgraph
这不起作用:
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
这很好用:
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:
如何在 azure 容器应用程序中设置 memgraph 容器?
在 Azure 容器应用程序中,不直接支持绑定安装。相反,您需要使用 Azure 文件 或 Azure 托管磁盘 来持久存储数据。
memgraphdata
)。Azure 容器应用程序支持将 Azure 文件作为卷安装。
使用 Azure CLI 创建带有已安装的 Azure 文件共享的容器应用程序。
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
使用
chmod
和 chown
授予适当的访问权限。挂载文件共享时,在容器中包含启动脚本以调整权限。
# Example entry script
chmod -R 777 /var/lib/memgraph
chown -R memgraph:memgraph /var/lib/memgraph
exec memgraph
YAML 文件,用于使用 Azure 文件部署 Memgraph 容器。
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
日志:
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 日志:
[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