-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
MONGO_VERSION=8 | ||
MONGO_PORT=27017 | ||
MONGO_UI_PORT=4321 | ||
MONGO_INITDB_ROOT_USERNAME=root | ||
MONGO_INITDB_ROOT_PASSWORD=zaq12wsx |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# MongoDB | ||
|
||
This repository contains two Docker Compose configurations for running MongoDB with a web-based UI: | ||
- A basic setup without authentication | ||
- A secure setup with username/password authentication | ||
|
||
## Environment Variables | ||
|
||
Create a `.env` file in the same directory with the following variables: | ||
|
||
```env | ||
MONGO_VERSION=6.0 | ||
# Required only for password-protected setup | ||
MONGO_INITDB_ROOT_USERNAME=admin | ||
MONGO_INITDB_ROOT_PASSWORD=your_secure_password | ||
``` | ||
|
||
## Basic Setup (No Authentication) | ||
|
||
To start MongoDB without authentication: | ||
|
||
```bash | ||
docker compose -f docker-compose.yml up -d | ||
``` | ||
|
||
## Secure Setup (With Authentication) | ||
|
||
To start MongoDB with password protection: | ||
|
||
```bash | ||
docker compose -f docker-compose-with-password.yml up -d | ||
``` | ||
|
||
## Accessing the Services | ||
|
||
- **MongoDB**: Available at `localhost:27017` for default | ||
- **MongoDB UI**: Access through your web browser at `http://localhost:4321` for default | ||
|
||
## Stopping the Services | ||
|
||
To stop and remove the containers: | ||
|
||
```bash | ||
# For basic setup | ||
docker compose -f docker-compose.yml down | ||
|
||
# For password-protected setup | ||
docker compose -f docker-compose-with-password.yml down | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
version: "3.4" | ||
|
||
services: | ||
mongo: | ||
image: mongo:${MONGO_VERSION} | ||
container_name: mongo | ||
environment: | ||
- MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME} | ||
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD} | ||
ports: | ||
- ${MONGO_PORT}:27017 | ||
cpus: 0.5 | ||
mem_limit: 256M | ||
healthcheck: | ||
test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet | ||
interval: 15s | ||
timeout: 10s | ||
retries: 5 | ||
start_period: 40s | ||
|
||
mongo-ui: | ||
container_name: mongo-ui | ||
image: ugleiton/mongo-gui | ||
depends_on: | ||
mongo: | ||
condition: service_healthy | ||
restart: always | ||
ports: | ||
- ${MONGO_UI_PORT}:4321 | ||
environment: | ||
- MONGO_URL=mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@mongo:27017 | ||
cpus: 0.25 | ||
mem_limit: 256M |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: "3.4" | ||
|
||
services: | ||
mongo: | ||
image: mongo:${MONGO_VERSION} | ||
container_name: mongo | ||
ports: | ||
- ${MONGO_PORT}:27017 | ||
cpus: 0.5 | ||
mem_limit: 256M | ||
healthcheck: | ||
test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet | ||
interval: 15s | ||
timeout: 10s | ||
retries: 5 | ||
start_period: 40s | ||
|
||
mongo-ui: | ||
container_name: mongo-ui | ||
image: ugleiton/mongo-gui | ||
depends_on: | ||
mongo: | ||
condition: service_healthy | ||
restart: always | ||
ports: | ||
- ${MONGO_UI_PORT}:4321 | ||
environment: | ||
- MONGO_URL=mongodb://mongo:27017 | ||
cpus: 0.25 | ||
mem_limit: 256M |