Skip to content

Instantly share code, notes, and snippets.

@mrsarm
Last active September 1, 2020 18:49
Show Gist options
  • Save mrsarm/8cf9bf757a5c4520fdae0cb35509cd03 to your computer and use it in GitHub Desktop.
Save mrsarm/8cf9bf757a5c4520fdae0cb35509cd03 to your computer and use it in GitHub Desktop.
docker-compose.yml mongo-latest: launch a MongoDB server with a volume attached to persist data across sessions
mongo-latest:
image: mongo
ports:
- "27017:27017"
volumes:
- mongo-data-latest:/data/db
# - `docker-compose up' to start MongoDB attached to the console, or `.. start' detached
# - Connect with `docker-compose run mongo-latest mongo HOSTIP/DBNAME'
# - `docker-compose stop' to stop the service if it was detached,
# otherwise just press Ctrl+C to stop
# - `docker-compose down' to shutdown and drop the container (the data will continue
# stored in the 'mongo-data-latest' volume)
# - `docker volume rm mongo-data-latest' to drop the data from the volume (first
# execute `docker-compose down')
# - `~/bin/docker-volume-cp mongo-data-latest mongo-data-latest-backup-DAY' to backup the
# DB to a new volume
@mrsarm
Copy link
Author

mrsarm commented Sep 1, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment