Skip to content

Instantly share code, notes, and snippets.

@dcaponi
Last active January 29, 2024 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcaponi/f9e72c651055d58cdfafb574ab3e69df to your computer and use it in GitHub Desktop.
Save dcaponi/f9e72c651055d58cdfafb574ab3e69df to your computer and use it in GitHub Desktop.
MongoDB Locally

Local MongoDB w/ Docker because Podman don't work on Apple Silicon

Steps

  • make dockerfile
services:
  mongo:
    image: mongodb/atlas
    privileged: true
    command: |
      /bin/bash -c "atlas deployments setup --type local --port 27778 --bindIpAll --username root --password root --force && tail -f /dev/null"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - 27778:27778
  • docker compose up
  • mongosh "mongodb://root:root@localhost:27778/?directConnection=true"
    • With the Quotes
  • mongorestore --archive=sampledata.archive --port=27778 --username=root --password=root
  • first time
docker compose up -d && \
mongosh "mongodb://root:root@localhost:27778/?directConnection=true"
mongorestore --archive=sampledata.archive --port=27778 --username=root --password=root
  • restart
docker compose up -d && \
mongosh "mongodb://root:root@localhost:27778/?directConnection=true"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment