Keep MongoDB off the Internet and its password out of git
MongoDB was published on 0.0.0.0:27017 with the default "example" root password. It now listens on 127.0.0.1 only (the apps use the Docker network), and the root password comes from MONGO_PASSWORD in a git-ignored .env file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ad82a96440
commit
0d6f8d95c3
+5
-3
@@ -5,10 +5,12 @@ services:
|
||||
image: mongo:latest
|
||||
container_name: mongodb
|
||||
ports:
|
||||
- "27017:27017"
|
||||
# Seulement depuis la machine elle-même : les applications passent par le réseau Docker
|
||||
- "127.0.0.1:27017:27017"
|
||||
environment:
|
||||
MONGO_INITDB_ROOT_USERNAME: root
|
||||
MONGO_INITDB_ROOT_PASSWORD: example
|
||||
# Mot de passe dans .env (MONGO_PASSWORD), hors du dépôt git
|
||||
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD:?MONGO_PASSWORD manquant dans .env}
|
||||
volumes:
|
||||
- mongodb_data:/data/db
|
||||
networks:
|
||||
@@ -20,7 +22,7 @@ services:
|
||||
depends_on:
|
||||
- mongodb
|
||||
environment:
|
||||
- MONGO_URI=mongodb://root:example@mongodb:27017/?authSource=admin
|
||||
- MONGO_URI=mongodb://root:${MONGO_PASSWORD:?MONGO_PASSWORD manquant dans .env}@mongodb:27017/?authSource=admin
|
||||
networks:
|
||||
- app-network
|
||||
volumes:
|
||||
|
||||
Reference in New Issue
Block a user