DATABASES = {
'default': {
'ENGINE': 'djongo',
'HOST': 'mongodb',
'PORT': 27017,
}
}
version: "3.9"
services:
server:
container_name: "server"
build: ./
ports:
- "4200:4200"
depends_on:
- mongodb
- elastic
restart: always
links:
- mongodb
- elastic
env_file: .env
mongodb:
container_name: "mongodb"
image: mongo:4.4.7-focal
restart: always
volumes:
- mongodb:/data/db
environment:
- MONGO_INITDB_ROOT_USERNAME=$MONGODB_ROOT_USER
- MONGO_INITDB_ROOT_PASSWORD=$MONGODB_ROOT_PASSWORD
ports:
- "27017:27017"
env_file: .env
elastic:
container_name: "elastic"
image: elasticsearch:7.13.4
restart: always
environment:
- discovery.type=single-node
- cluster.name=elastic-crm
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- ELASTIC_USERNAME=$ELASTIC_USERNAME
- ELASTIC_PASSWORD=$ELASTIC_PASSWORD
ports:
- "9200:9200"
volumes:
- elastic:/usr/share/elasticsearch/data
env_file: .env
volumes:
mongodb:
elastic:
links
присоединяем два этих сервиса к бекенду, а в бекенде вместо localhost используем имя сервиса. Ну и порты тоже указываем правильные.connect("mongodb://mongodb:27017/");
//версия указана?
services:
mongodb:
image: mongo:latest
restart: always
ports: //порт ещё
- 27017:27017
networks:
- site
web:
build: ./src
restart: always
command: python src/manage.py runserver 0.0.0.0:8000
ports:
- 8000:8000
networks:
- site
networks:
site:
driver: bridge