liveBook · Manning

Docker Compose

As explained in AI Agents in Action, Second Edition

Docker Compose is a tool for defining and running multi-container applications from a declarative configuration file.

Docker Compose defines and runs a multi-container application from one declarative YAML file. Instead of starting and wiring each microservice separately, a single command brings up the complete stack. section 8.2.2

Listing 8.5 docker-compose.yaml
version: "3.9"    #1
services:
  web:    #2
    build: ./web
    container_name: realtime-voice-web
    ports: ["8000:8000"]
    environment:    #3
      OPENAI_API_KEY: ${OPENAI_API_KEY}
      DEFAULT_MODEL: ${DEFAULT_MODEL:-gpt-4o-realtime-preview-2025-06-03}
      DEFAULT_VOICE: ${DEFAULT_VOICE:-alloy}
      ALLOWED_ORIGINS: ${ALLOWED_ORIGINS:-*}
    depends_on:
      - image_agent
      - web_agent

  image_agent:    #4
    build: ./image_agent
    container_name: realtime-image-agent
    ports: ["8001:8000"]
    environment:
      OPENAI_API_KEY: ${OPENAI_API_KEY}

  web_agent:    #5
    build: ./web_agent
    container_name: realtime-web-agent
    ports: ["8002:8000"]
    environment:
      OPENAI_API_KEY: ${OPENAI_API_KEY}
      WEB_AGENT_MODEL: ${WEB_AGENT_MODEL:-gpt-5-mini}

The Compose file organizes services, build directories, container names, ports, environment variables, and startup dependencies. section 8.2.2

A practical Compose workflow is:

  • Prepare the environment file and set required values such as OPENAI_API_KEY. section 8.5
  • Run docker compose up --build to build images and start the stack. section 8.2.2 section 8.5
  • Open the local web interface, inspect logs, verify service routing, and stop the stack with docker compose down. section 8.5

A three-service agent stack

A Compose deployment can run realtime-voice-web, realtime-image-agent, and realtime-web-agent together. The web service exposes port 8000, depends on the agent services, and routes image or web requests to specialized containers. section 8.2.2

How AI Agents in Action, Second Edition covers it

How deep it goes
Defines services, builds, ports, environment variables, and dependencies, but does not detail container networking internals.
Examples
Uses a three-container agent stack, docker-compose.yaml, .env configuration, localhost:8000, logs, and optional localtunnel demos.
What it assumes
Assumes Docker Desktop, a terminal, a cloned project, and configured environment variables.
What you can do after
Operate/configure a local multi-agent stack by preparing environment variables, building services, checking routing, viewing logs, and stopping containers.
How it connects
Connects Docker containers, microservices, environment variables, Docker Desktop, agent orchestration, and local tunneling.

Also explained in

Compare how 15 books explain Docker Compose →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Agents in Action, Second Edition. The section links point to the parts of the book it draws on.