Dockercompose in docker

Docker Compose defines multi-container applications in a YAML file. It lets you run your frontend, backend, and database together with one command: docker-compose up.

Example

version: '3.8'
services:
  frontend:
    build: ./client
    ports: ['3000:3000']
  backend:
    build: ./server
    ports: ['5000:5000']
    environment:
      - MONGO_URI=mongodb://db:27017/myapp
  db:
    image: mongo:6
    volumes: ['mongo-data:/data/db']
volumes:
  mongo-data:

This docker-compose.yml runs a full MERN stack — React frontend, Node.js backend, and MongoDB database with persistent storage.