liveBook · Manning

Docker Compose

As explained in gRPC Microservices in Go

A Docker Compose file is a YAML configuration file that defines and configures multi-container Docker applications and their services.

Docker Compose uses a YAML file to define and run a multi-container application stack. In end-to-end testing, it assembles microservices, databases, dependencies, and test-accessible ports into a repeatable environment. section 7.4.1 section 7.4.3

A Compose service definition commonly specifies:

  • build, which identifies the Dockerfile path used to build a service image. section 7.4.2
  • environment, which supplies configuration such as application ports, database URLs, and runtime modes. section 7.4.2 section 7.4.6
  • depends_on, which expresses prerequisite services; healthcheck, which prevents startup readiness from being confused with application readiness. section 7.4.2
  • ports and volumes, which expose services externally and mount local resources into containers. section 7.4.2

Compose a test database and services

Place docker-compose.yml and database migration files under an end-to-end test module. Define a MySQL 8.0.30 service with a mounted init.sql file, a root password, and a health check that retries mysqladmin ping up to 20 times. The initialization script creates payments and orders databases; then run the stack with `cd resources && docker-compose up`. Add payment and order services with Dockerfile builds, dependency conditions, exposed ports, and service-specific connection settings. section 7.4.3 section 7.4.4 section 7.4.6

Figure 7.6 Application stack that test suite runs against

Use the application-stack diagram to inspect how the database and microservices are assembled for the end-to-end test suite. section 7.4.1

How gRPC Microservices in Go covers it

How deep it goes
Defines YAML structure, service fields, health checks, database initialization, and service-specific configuration.
Examples
Uses MySQL 8.0.30, mounted SQL initialization, payment and order services, exposed ports, and Docker Compose CLI commands.
What it assumes
Assumes familiarity with Docker, Dockerfiles, YAML, and service-level configuration.
What you can do after
Operate a configured test stack through Docker Compose with service dependencies, readiness checks, mounted resources, and runtime settings.
How it connects
Connects Dockerfiles, Docker images, environment variables, health checks, MySQL, and end-to-end testing.

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 gRPC Microservices in Go. The section links point to the parts of the book it draws on.