I'm running a mongoDB as a docker container on my ubuntu server. Yesterday the db got hacked and I do not understand what is configured wrong. Ok, I'm just using the default configuration - which I guess - is not the best way. But I thought the db is only accessable from my internal container, as I'm using docker. So this is obviously wrong.
I would like to understand why this docker-compose file gives me an insecure mongoDB:
version: '3.5'
networks:
reverse-proxy:
name: reverse-proxy
driver: bridge
volumes:
html:
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
networks:
- reverse-proxy
ports:
- "80:80"
- "443:443"
volumes:
- /opt/nginx-proxy/vhost.d:/etc/nginx/vhost.d:rw
- /opt/nginx-proxy/htpasswd:/etc/nginx/htpasswd:ro
- /opt/nginx/certs:/etc/nginx/certs:ro
- html:/usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
mongodb:
container_name: mongodb
image: mongo:4.0
networks:
- reverse-proxy
restart: unless-stopped
ports:
- "27017:27017"
volumes:
- /opt/mongo/data:/data/db
- /restore:/restore