Sobes.tech
Middle+

What is Docker Compose? Why is it needed?

sobes.tech AI

Answer from AI

Docker Compose is a tool for defining and running multi-container Docker applications. With the docker-compose.yml file, you can describe the configuration of multiple services, their images, networks, volumes, and dependencies.

Why use Docker Compose:

  • Simplifies the launch of complex applications with multiple containers (e.g., web server + database).
  • Allows running all services with a single command docker-compose up.
  • Eases configuration management and scaling.

Example docker-compose.yml for a web application with a database:

version: '3'
services:
  web:
    build: ./web
    ports:
      - "5000:5000"
    depends_on:
      - db
  db:
    image: postgres:13
    environment:
      POSTGRES_PASSWORD: example

Run: docker-compose up — will bring up both containers and set up the network between them.

What is Docker Compose? Why is it needed? — QA / QA… - sobes.tech