I am trying to run a MongoDB container on a DigitalOcean droplet and so created a new dir with mkdir -pv mongodb/data then inside mongodb I created a new file with touch mongodb.conf then edited it with nano mongodb.conf so that it looks like this:
systemLog:
destination: file
path: "/var/log/mongodb/mongod.log"
logAppend: true
storage:
journal:
enabled: true
processManagement:
fork: true
net:
bindIp: 0.0.0.0
port: 27017
setParameter:
enableLocalhostAuthBypass: false
I then used the same process to create a file docker-compose.yml Which looks like:
version: "3.8"
services:
mongodb:
image: mongo:latest
container_name: mongodb
environment:
- PUID=1000
- PGID=1000
volumes:
- /mongodb/mongod.conf:/etc/mongod.conf
- /mongodb/data:/data/db
command: ["mongod", "--config", "/etc/mongod.conf"]
ports:
- 0.0.0.0:27017:27017
This makes the filesystem look like:
.
├── mongodb
│ ├── data
│ ├── docker-compose.yml
│ └── mongod.conf
When I then try running docker-compose up it gives the error:
mongodb | grep: /etc/mongo/mongod.conf: Is a directory
mongodb | error: unexpected "js-yaml.js" output while parsing config:
mongodb | undefined
mongodb exited with code 1
I have also tried changing the command to: command: ["mongod", "-f", "/etc/mongod.conf"] but this gives a similar error:
mongodb | Error opening config file: Is a directory
mongodb | try 'mongod --help' for more information
mongodb exited with code 2
Any help to solve this would be appreciated.