Expected behavior
An image created from a Dockerfile mounts a custom shared volume with pre-existing data when run. The volume contains a database with a single table with 12 entries.
Actual behavior
Outputs the error “Invalid directory for database creation.”
Additional Information
The following command line is successful:
docker run -p 8000:8000 -v $(pwd)/local/dynamodb:/data/ amazon/dynamodb-local -jar DynamoDBLocal.jar -sharedDb -dbPath /data
And the following Dockerfile is successful for the default shared database, however it does not persist changes to the data between runs.
FROM amazon/dynamodb-local
EXPOSE 8000/tcp
WORKDIR /home/dynamodblocal
VOLUME dynamodata:/home/dynamodblocal
CMD ["-jar", "DynamoDBLocal.jar", "-sharedDb", "-dbPath", "."]
The Dockerfile I am attempting is to recreate the successful command line with the successful Dockerfile structure:
FROM amazon/dynamodb-local
EXPOSE 8000/tcp
VOLUME ["/local/dynamodb:/data/"]
CMD ["-jar", "DynamoDBLocal.jar", "-sharedDb", "-dbPath", "/data"]
I am unable to determine why /data
is not a valid dbPath
here when it was successful on the command line. I have tried to give it a full path, the directory path only (local/dynamodb) (which does exist, btw), and I tried changing my working directory to the path with the volume.
Steps to reproduce the behavior
- Create a Dockerfile with the last given code.
- Open terminal and type
docker build -t test .
- Type
docker run -p 8000:8000 test