This commit is contained in:
wandoubaba 2024-03-02 10:19:42 +08:00
commit 8f16b57333
4 changed files with 98 additions and 0 deletions

39
README.md Normal file
View File

@ -0,0 +1,39 @@
# docker-mongo
A docker based mongodb server.
## Usage
```sh
git clone https://git.wandoubaba.com/wandoubaba/docker-mongo.git
cd docker-mongo
docker compose up -d
```
## Configuration
### Password
Edit `docker-compose.yml`:
```yml
MONGO_INITDB_ROOT_USERNAME: username
MONGO_INITDB_ROOT_PASSWORD: password
```
### Port
Edit `conf/mongod.conf`:
```conf
net:
port: 27017
```
### Timezone
Edit `docker-compose.yml`
```yml
TZ: Asia/Shanghai
```

39
conf/mongod.conf Normal file
View File

@ -0,0 +1,39 @@
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /data/db
# engine:
# wiredTiger:
# where to write logging data.
# systemLog:
# destination: file
# logAppend: true
# path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:

2
data/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

18
docker-compose.yml Normal file
View File

@ -0,0 +1,18 @@
version: "3.1"
services:
mongo:
image: mongo:7.0
container_name: mongo
restart: always
environment:
TZ: Asia/Shanghai
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: password
MONGO_INITDB_DATABASE: default
volumes:
- ./data:/data
- ./conf:/etc/mongo
network_mode: host
command: ['mongod', '--config', '/etc/mongo/mongod.conf']