Mounting volume with mongodb-atlas-local wipes out /data/configdb

Hello! I’m running my service following the instructions in the guide, where data-app is my existing volume:

services:
  local_dev_atlas:
    image: mongodb/mongodb-atlas-local
    hostname: local_dev_atlas
    ports:
      - 27017:27017
    environment:
      - MONGODB_INITDB_ROOT_USERNAME=user
      - MONGODB_INITDB_ROOT_PASSWORD=pass
    volumes:
      - data-app:/data/db
      - data-config:/data/configdb
volumes:
  - data-app:
  - data-config:

When I run this container, data/db is successfully mounted with data from my volume, but data/configdb is empty and I run into Error reading file /data/configdb/keyfile: No such file or directory. How can I persist /data/configdb and /data/mongot from the base image?

The container starts up with the correct files from the base image when I don’t mount my data-app volume

Hi @Afrah_Ali when I try to run docker compose up with your example docker-compose file I hit an error caused by the “-” before the volumes. Removing these to match the following, and then doing compose up and down (and then up again) I can’t replicate the keyfile issue.

volumes:
    data-app:
    data-config:

While you’re working on the compose file, you might want to consider passing the logging to stderr (if you continue to see issues, feel free to send over these logs):

    environment:
     - MONGOT_LOG_FILE=/dev/stderr 

Finally, you mention mongot; you can mount this volume too:

    volumes
    - mongot:/data/mongot
...
volumes:
    mongot:

You can use this complete example for reference, which also includes sending mongot logs to stderr:

services:
  local_dev_atlas:
    image: mongodb/mongodb-atlas-local
    hostname: local_dev_atlas
    ports:
      - 27017:27017
    environment:
      - MONGODB_INITDB_ROOT_USERNAME=user
      - MONGODB_INITDB_ROOT_PASSWORD=pass
      - MONGOT_LOG_FILE=/dev/stderr
      - RUNNER_LOG_FILE=/dev/stderr
    volumes:
      - data-app:/data/db
      - data-config:/data/configdb
      - mongot:/data/mongot
volumes:
  data-app:
  data-config:
  mongot:

Let me know how you get on.

Thank you for the fast response! I’ve also mounted the mongot volume from your example, but I’m running into the same keyfile issue (empty /configdb and /mongot folders while /data while is successfully mounted) Here is the log:

2025-06-10 12:56:55 {"t":{"$date":"2025-06-10T16:56:55.981Z"},"s":"I",  "c":"CONTROL",  "id":5760901, "ctx":"main","msg":"Applied --setParameter options","attr":{"serverParameters":{"mongotHost":{"default":"","value":"localhost:27027"},"searchIndexManagementHostAndPort":{"default":"","value":"localhost:27027"}}}}
2025-06-10 12:56:55 {"t":{"$date":"2025-06-10T16:56:55.986+00:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
2025-06-10 12:56:55 {"t":{"$date":"2025-06-10T16:56:55.987+00:00"},"s":"I",  "c":"CONTROL",  "id":5945603, "ctx":"main","msg":"Multi threading initialized"}
2025-06-10 12:56:55 {"t":{"$date":"2025-06-10T16:56:55.987+00:00"},"s":"I",  "c":"NETWORK",  "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set at least one of the related parameters","attr":{"relatedParameters":["tcpFastOpenServer","tcpFastOpenClient","tcpFastOpenQueueSize"]}}
2025-06-10 12:56:55 {"t":{"$date":"2025-06-10T16:56:55.987+00:00"},"s":"I",  "c":"ACCESS",   "id":20254,   "ctx":"main","msg":"Read security file failed","attr":{"error":{"code":30,"codeName":"InvalidPath","errmsg":"Error reading file /data/configdb/keyfile: No such file or directory"}}}
2025-06-10 12:56:55 {"t":{"$date":"2025-06-10T16:56:55.987+00:00"},"s":"I",  "c":"ASIO",     "id":6529201, "ctx":"main","msg":"Network interface redundant shutdown","attr":{"state":"Stopped"}}
2025-06-10 12:56:55 {"t":{"$date":"2025-06-10T16:56:55.987+00:00"},"s":"I",  "c":"ASIO",     "id":22582,   "ctx":"main","msg":"Killing all outstanding egress activity."}
2025-06-10 12:56:55 {"t":{"$date":"2025-06-10T16:56:55.987+00:00"},"s":"I",  "c":"ASIO",     "id":6529201, "ctx":"main","msg":"Network interface redundant shutdown","attr":{"state":"Stopped"}}
2025-06-10 12:56:55 {"t":{"$date":"2025-06-10T16:56:55.987+00:00"},"s":"I",  "c":"ASIO",     "id":22582,   "ctx":"main","msg":"Killing all outstanding egress activity."}
2025-06-10 12:56:55 {"t":{"$date":"2025-06-10T16:56:55.987+00:00"},"s":"I",  "c":"ASIO",     "id":6529201, "ctx":"main","msg":"Network interface redundant shutdown","attr":{"state":"Stopped"}}
2025-06-10 12:56:55 {"t":{"$date":"2025-06-10T16:56:55.987+00:00"},"s":"I",  "c":"ASIO",     "id":22582,   "ctx":"main","msg":"Killing all outstanding egress activity."}
2025-06-10 12:56:55 {"t":{"$date":"2025-06-10T16:56:55.988+00:00"},"s":"I",  "c":"SHARDING", "id":5847201, "ctx":"main","msg":"Balancer command scheduler stop requested"}
2025-06-10 12:56:55 {"t":{"$date":"2025-06-10T16:56:55.988+00:00"},"s":"I",  "c":"ASIO",     "id":6529201, "ctx":"main","msg":"Network interface redundant shutdown","attr":{"state":"Stopped"}}
2025-06-10 12:56:55 {"t":{"$date":"2025-06-10T16:56:55.988+00:00"},"s":"I",  "c":"ASIO",     "id":22582,   "ctx":"main","msg":"Killing all outstanding egress activity."}
2025-06-10 12:56:55 {"t":{"$date":"2025-06-10T16:56:55.988+00:00"},"s":"F",  "c":"CONTROL",  "id":20575,   "ctx":"main","msg":"Error creating service context","attr":{"error":"Location5579201: Unable to acquire security key[s]"}}
2025-06-10 12:56:55 {"time":"2025-06-10T16:56:55.92299058Z","level":"DEBUG","msg":"starting server..."}
2025-06-10 12:58:55 Error: error checking mongod: error pinging: server selection error: server selection timeout, current topology: { Type: ReplicaSetNoPrimary, Servers: [{ Addr: localhost:27017, Type: Unknown, Last error: dial tcp [::1]:27017: connect: connection refused }, ] }
2025-06-10 12:58:55 Usage:
2025-06-10 12:58:55   runner server [flags]
2025-06-10 12:58:55 
2025-06-10 12:58:55 Flags:
2025-06-10 12:58:55   -h, --help   help for server
2025-06-10 12:58:55 
2025-06-10 12:58:55 panic: error checking mongod: error pinging: server selection error: server selection timeout, current topology: { Type: ReplicaSetNoPrimary, Servers: [{ Addr: localhost:27017, Type: Unknown, Last error: dial tcp [::1]:27017: connect: connection refused }, ] }
2025-06-10 12:58:55 
2025-06-10 12:58:55 goroutine 1 [running]:
2025-06-10 12:58:55 main.main()
2025-06-10 12:58:55 /app/cmd/runner/main.go:65 +0x165

For some context, I’m switching from using the official mongo image to the Atlas local and mounting the same data volume, could there be some metafiles there that are conflicting with the base image setup?

Yes, I’d suggest using mongodump from your old mongo-based container, then mongorestore into your new mongodb-atlas-local-based container.

You can configure the mongodb-atlas-local container to initialize with data on docker compose up in the Docker Compose file by using initdb:

volumes:
      - ./init:/docker-entrypoint-initdb.d
      - db:/data/db
      - configdb:/data/configdb
      - mongot:/data/mongot

Then you can place the dump archive and init script in the init folder relative to your compose file, something like:

# init/init.sh
#!/bin/bash

mongorestore --uri "$CONNECTION_STRING" --archive=./my-data.archive
echo "Sample data loaded successfully."
1 Like

Starting up the container with my data archive did the trick, thank you for your help!

Might be worth mentioning in the Convert Official Image to a Local Atlas Deployment section

1 Like

Great! I’m pleased to hear this is working for you now. I’ve requested the documentation changes - thanks for your feedback!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.