Sobes.tech
Junior — Middle

How can you run a multi-container application using docker-compose?

sobes.tech AI

Answer from AI

To launch a multi-container application using docker-compose, you need to create a docker-compose.yml file that describes all services (containers), their images, ports, volumes, and networks. Then, in the directory with this file, run the command:

docker-compose up

This will start all the described containers and connect them according to the configuration. To run in detached mode, use the -d flag:

docker-compose up -d

An example of a simple docker-compose.yml for an application with a web server and a database:

version: '3'
services:
  web:
    image: my-web-app:latest
    ports:
      - "8080:80"
    depends_on:
      - db
  db:
    image: postgres:13
    environment:
      POSTGRES_PASSWORD: example
How can you run a multi-container application using… - sobes.tech