invalid mount path: 'db' mount path must be absolute

Viewed 5238

Following is my docker file :

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

Following is the docker compose file :

version: "3.3" 
services:   
dynamodb:
build:
  context: .
  dockerfile: dynamodb/Dockerfile
container_name: email_dynamo
ports:
  - "8000:8000"
volumes:
  - dynamodb-local:/home/dynamodblocal/db   
seed:
image: amazon/aws-cli
container_name: email_dynamo_seed
links:
  - dynamodb
depends_on:
  - dynamodb
command: sh -c "~/seed/seed.sh"
entrypoint: []
volumes:
  - ~/.aws:/root/.aws
  - ./seed:/root/seed 
volumes:   
   dynamodb-local:
    driver: local

When I try to run docker-compose up , getting the following error :

Building with native build. Learn about native build in Compose here: https://docs.docker.com/go/compose-native-build/ Recreating 89162581ebc2_email_dynamo ... error

ERROR: for 89162581ebc2_email_dynamo Cannot create container for service dynamodb: invalid volume specification: '6cf8eb4d8edc2203adc35064b97ce90adc306c1e136a77a2e5e6203647564cd5:db:rw': invalid mount config for type "volume": invalid mount path: 'db' mount path must be absolute

ERROR: for dynamodb Cannot create container for service dynamodb: invalid volume specification: '6cf8eb4d8edc2203adc35064b97ce90adc306c1e136a77a2e5e6203647564cd5:db:rw': invalid mount config for type "volume": invalid mount path: 'db' mount path must be absolute ERROR: Encountered errors while bringing up the project.

1 Answers

The path in VOLUME option must be an exists path in the container. In your case need to change VOLUME ["./db"] to this: VOLUME ["/home/dynamodblocal/db"]

And the WORKDIR sets the default directory only for RUN, CMD, ENTRYPOINT, COPY and ADD commands. Not works with VOLUME!

Related