Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MongoDB in Docker compose

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

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:
pytest

pymongo
motor

docker-compose up
docker exec -it mongodb_app_1 bash