MongoDB in Docker compose



examples/mongodb/Dockerfile
FROM python:3
WORKDIR /opt
COPY requirements.txt .
RUN pip install -r requirements.txt
# COPY . .

examples/mongodb/docker-compose.yml
version: '3'
services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    tty: true
    command: bash
    volumes:
      - .:/opt

  mongodb:
    image: mongo:4.0.8
    volumes:
      - mongo-data:/data/db
      - mongo-configdb:/data/configdb

volumes:
  mongo-data:
  mongo-configdb:

examples/mongodb/requirements.txt
pytest

pymongo
motor

docker-compose up


docker exec -it mongodb_app_1 bash