Sobes.tech
Junior — Middle

What is the main function of Docker Compose and why is it used in container management?

sobes.tech AI

Answer from AI

Docker Compose is used to define and run multi-container Docker applications. Its main function is to describe the configuration of multiple containers in a single YAML file (usually docker-compose.yml), including images, networks, volumes, and environment variables. This allows you to run and manage the entire set of services with one command, simplifying orchestration and environment setup for development, testing, and deployment.

Example of a simple docker-compose.yml:

version: '3'
services:
  web:
    image: nginx
    ports:
      - "80:80"
  db:
    image: postgres
    environment:
      POSTGRES_PASSWORD: example

To start all services: docker-compose up.