You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Docker Compose启动DynamoDB Local容器报错:无效挂载路径'db',挂载路径需为绝对路径

Fixing "Invalid Mount Path" Error with DynamoDB Local Docker Deployment

Hey there, let's get that DynamoDB Local container up and running smoothly! The error you're hitting boils down to one simple rule: Docker requires container-side volume mount paths to be absolute, and your Dockerfile is using a relative path that Docker can't resolve.

The Root Cause

In your Dockerfile, the line VOLUME ["./db"] is causing the issue. Docker doesn't accept relative paths for volume mounts inside containers—this is exactly why you're seeing the invalid mount path: 'db' mount path must be absolute message.

The Fix

Update your Dockerfile to use an absolute path for the VOLUME directive. Since you've set WORKDIR /home/dynamodblocal, your ./db directory lives at /home/dynamodblocal/db inside the container. Here's the corrected Dockerfile:

FROM amazon/dynamodb-local
WORKDIR /home/dynamodblocal
RUN mkdir ./db && chown -R 1000 ./db
CMD ["-jar", "DynamoDBLocal.jar", "-dbPath", "./db", "-sharedDb"]
VOLUME ["/home/dynamodblocal/db"]

Why This Works

  • The VOLUME directive now points to an absolute path inside the container, which Docker recognizes as a valid mount point.
  • Your CMD still uses ./db for -dbPath—that's totally fine! It’s relative to the WORKDIR you set, so DynamoDB will still find the correct database directory.
  • Your docker-compose.yml is already configured correctly: it maps the dynamodb-local named volume to /home/dynamodblocal/db, which matches the updated VOLUME path perfectly.

Next Steps

Run this command to rebuild and restart your containers:

docker-compose up --build

This should eliminate the volume path error, and your DynamoDB Local container should start up without issues.

内容的提问来源于stack exchange,提问作者Prasenjit

火山引擎 最新活动