Sobes.tech
Junior — Middle

Explain what Docker Compose is and how it is used to manage multi-container applications.

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 containers, their networks, volumes, and dependencies.

Using Docker Compose allows you to start all services with a single command docker-compose up, which simplifies managing complex applications consisting of a database, web server, cache, and other components.

An example of a simple docker-compose.yml for a PHP application with a MySQL database:

version: '3'
services:
  web:
    image: php:7.4-apache
    volumes:
      - ./src:/var/www/html
    ports:
      - "8080:80"
  db:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: example
      MYSQL_DATABASE: testdb
Explain what Docker Compose is and how it is used to… - sobes.tech