Persisting data in local container based version of atlas

Hi @Michael_Lasevich , looks like you’re just missing hostname in your compose file. This is a little buried in our documentation (here) at the moment, but we’re working on improving that right now.

This (hostname) is essential for the local replicaset to function correctly, and is required to ensure communication between the different services within the same Docker Container network is possible, by being able to refer to this container by the same hostname between runs.

Here’s how I modified your compose file:

services:
  mongo:
    image: mongodb/mongodb-atlas-local
    container_name: 'mongo'
    restart: unless-stopped    
    hostname: mongodb
    ports:
      - 27018:27017
    volumes:
      - mongodb_config:/data/configdb
      - mongodb_data:/data/db

volumes:
  mongodb_data:
  mongodb_config:

To use this, you may find you need to docker compose down -v to remove old config data (note that any data will be removed at this point too) before doing docker compose up, and then go back to docker compose down when you want to stop the container and persist the data.

1 Like