Permission error on mongodb-atlas-local with volume

Hi, I’m trying to use mongo with atlas search on local development and local docker image.

When I add volume to docker-compose:

  mongo:
    image: mongodb/mongodb-atlas-local:latest
    environment:
      - MONGODB_INITDB_ROOT_USERNAME=${MONGO_DB_USERNAME}
      - MONGODB_INITDB_ROOT_PASSWORD=${MONGO_DB_PASSWORD}
    ports:
      - 27018:27017
    volumes:
      - ${DATA_DIRECTORY}/${MONGO_DB_ATLAS_DIRECTORY}/data:/data/db
      - ./mongo_init:/mongo_init

I get an error:

Error: error initializing: error writing key file: open /data/configdb/keyfile: permission denied

I tried different set of privileges (999:999, 993:994 etc). I have docker ignore with data folder. I don’t know what else I should test.

I would appreciate any advice.

1 Like

hi
have do solved this issue?

unfortunately I still have this problem

@Do_Gier @Brian_Shen have a look here:

I am having this same issue using it exactly as shown in the documentation: https://www.mongodb.com/docs/atlas/cli/current/atlas-cli-deploy-docker/#persist-data-across-runs-with-docker-compose

For others experiencing the same problem, I found a viable workaround.

You can also add a volume for /data/configdb and it will no longer have this error on subsequent starts.

services:
  mongodb:
    image: mongodb/mongodb-atlas-local:7.0.12
    volumes:
      - db-data:/data/db
      - db-config:/data/configdb
volumes:
  db-data:
  db-config: