Skip to content

Instantly share code, notes, and snippets.

@crazyoptimist
Last active April 9, 2024 23:20
Show Gist options
  • Save crazyoptimist/6b70fba82c5f02347579d825b61894e3 to your computer and use it in GitHub Desktop.
Save crazyoptimist/6b70fba82c5f02347579d825b61894e3 to your computer and use it in GitHub Desktop.
MongoDB Docker Deployment
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:
@kevinadhiguna
Copy link

Hi, thank you for the YAML. May I know how to add timezone in MongoDB docker-compose ?

@crazyoptimist
Copy link
Author

crazyoptimist commented Feb 22, 2022

I think this link might help, I haven't tried it.

@kevinadhiguna
Copy link

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

@crazyoptimist
Copy link
Author

Great!

@crazyoptimist
Copy link
Author

crazyoptimist commented May 30, 2022

You can run mongo5+ only on a server of which CPU supports AVX.

@konstantinos2018
Copy link

Thank you

@crazyoptimist
Copy link
Author

Glad it helped :)

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