liveBook · Manning

YAML

As explained in Learn Docker in a Month of Lunches, Second Edition

YAML is a human-readable serialization format commonly used for configuration data.

When a command grows into a set of application settings or build steps, YAML puts those settings in a readable file. Indentation matters: spaces show which properties belong to which object. The meaning of the properties depends on the tool reading the file. section 7.1 section 16.1

Listing 7.1 A Docker Compose file to run the to-do app
services:

  todo-web:
    image: diamol/ch06-todo-list:2e
    ports:
      - "8020:80"
    networks:
      - app-net

networks:
  app-net:
    name: nat
    external: true

In this Compose file, `services` and `networks` are top-level entries. The indented `todo-web` service specifies an image, a port mapping, and a network. `external: true` identifies `nat` as an existing Docker network. section 7.1

To try the Compose file, create the `nat` network if needed, then run `docker compose up` from the file’s directory. Compose reads the desired state and asks Docker to create the resources needed to run the app. section 7.1

Listing 16.3 A simple GitHub workflow to run a PowerShell script
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - name: build
        working-directory: cicd
        run: ./build.ps1
        shell: pwsh

YAML also defines GitHub Actions workflows. Here, an indented `build` job runs on `ubuntu-latest`, checks out the repository, and runs `./build.ps1` with PowerShell. Keeping most build logic in the script makes it easier to run locally and move to another build provider than putting it all in provider-specific workflow steps. section 16.1

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains indentation through a Compose file and illustrates workflow job configuration, without developing a general YAML syntax guide.
Examples
Shows a single-service Compose file and a GitHub Actions job that checks out code and runs a PowerShell build script.
What it assumes
Introduces YAML indentation directly; assumes Docker for the Compose task and GitHub, Git, and PowerShell for the workflow exercise.
What you can do after
Operate/configure it by reading a Compose file, starting its app, and defining a GitHub Actions build job.
How it connects
Connects YAML to JSON, Docker Compose services and networks, and GitHub Actions workflows.

Also explained in

Compare how 16 books explain YAML →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.