Last active
April 9, 2024 23:20
-
-
Save crazyoptimist/6b70fba82c5f02347579d825b61894e3 to your computer and use it in GitHub Desktop.
MongoDB Docker Deployment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: mongodb | |
services: | |
mongodb: | |
container_name: mongo | |
image: mongo:7 | |
volumes: | |
- mongodb_data:/data/db/ | |
ports: | |
- 27017:27017 | |
environment: | |
MONGO_INITDB_ROOT_USERNAME: user | |
MONGO_INITDB_ROOT_PASSWORD: youmayneverguess | |
command: --quiet | |
logging: | |
driver: "json-file" | |
options: | |
max-size: "200k" | |
max-file: "10" | |
restart: always | |
volumes: | |
mongodb_data: |
Glad it helped!
This really worked like charm.
Edit:
command: --quiet
Added it to shut up the too verbose docker compose log.
Edit:
docker compose version 2 doesn't create the bind mounted dir automatically, so you will need to create the directory manually before running it:
mkdir db_data
Or just do not use bind mount if you don't have a reason for it.
Hi, thank you for the YAML. May I know how to add timezone in MongoDB docker-compose ?
I think this link might help, I haven't tried it.
Thanks, I got the timezone worked with :
...
environment:
MONGO_INITDB_ROOT_USERNAME: your_username
MONGO_INITDB_ROOT_PASSWORD: your_strong_password
TZ: "Europe/London"
...
List of timezone : Setting Local Time in Docker
Great!
You can run mongo5+ only on a server of which CPU supports AVX.
Thank you
Glad it helped :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks