liveBook · Manning

YAML

As explained in Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform

YAML is a human-readable data serialization and configuration format designed for structured machine-readable documents.

YAML is a human-readable format for structured, machine-readable documents. In a microservices application, a YAML file can describe how Docker Compose builds and launches containers, or how Kubernetes deploys a service. section 4.3.2 section 8.9.1

A Docker Compose YAML file can assemble a service configuration from small, readable fields:

  • Declare the Compose version and the services collection. section 4.3.2
  • Define a service with an image name, build context, Dockerfile, and container name. section 4.3.2
  • Configure port bindings, environment variables, and restart behavior. section 4.3.2
  • Keep the application-level Compose file in the root directory while placing each microservice in its own subdirectory. section 4.3.2

A service definition

The file can define a video-streaming service with image video-streaming, build context ./video-streaming, Dockerfile Dockerfile, port mapping 4000:80, environment variable PORT=80, and restart behavior set to no. section 4.3.2

Listing 4.1 Docker Compose file for our microservice
version: '3'                           #1
services:                              #2
 
  video-streaming:                     #3
    image: video-streaming             #4
    build:                             #5
      context: ./video-streaming       #6
      dockerfile: Dockerfile           #7
    container_name: video-streaming    #8
    ports:                             #9
     - "4000:80"                       #10
    environment:                       #11
      - PORT=80                        #12
    restart: "no"                      #13

Inspect the complete Compose listing to connect YAML fields with image building, container naming, port binding, environment configuration, and restart behavior. section 4.3.2

How Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform covers it

How deep it goes
Demonstrates concrete fields and project placement for Compose, while stopping short of general YAML syntax or parser internals.
Examples
Uses a video-streaming Compose service with build, image, ports, environment, container-name, and restart settings.
What it assumes
Assumes familiarity with microservices, Dockerfiles, containers, and Docker Compose project organization.
What you can do after
Operate and configure a containerized microservice through a Docker Compose YAML file.
How it connects
Connects YAML with Docker Compose, Dockerfile, containers, microservices, Kubernetes, and continuous deployment.

Also explained in

Compare how 16 books explain YAML →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform. The section links point to the parts of the book it draws on.