liveBook · Manning

PostgreSQL

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

Postgres is an open-source relational database management system.

PostgreSQL is an open-source relational database for applications that outgrow a file-based SQLite database. Docker Compose can run the application and database as separate services. section 7.4

A Compose configuration connects the application to PostgreSQL by:

  • Running a PostgreSQL service from the diamol/postgres:2e-12 image. section 7.4
  • Publishing container port 5432 as host port 5433 and exposing the service as todo-db on the Compose network. section 7.4
  • Selecting the Postgres provider through Database:Provider and supplying the connection string through a mounted secret file. section 7.4
Listing 7.3 Compose services for an app with a Postgres database
services:

  todo-db:
    image: diamol/postgres:2e-12  
    ports:
      - "5433:5432"
    networks:
      - app-net

  todo-web:
    image: diamol/ch06-todo-list:2e
    ports:
      - "8020:80"
    environment:
      - Database:Provider=Postgres
    depends_on:
      - todo-db
    networks:
      - app-net
    secrets:
      - source: postgres-connection
        target: /app/config/secrets.json

Inspect the complete Compose services for the PostgreSQL database and to-do application. section 7.4

Run the application

From the exercise directory, run docker compose up -d, or use the Windows Compose file, then run docker compose ps to verify the containers.

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

How deep it goes
Explains service configuration, networking, provider selection, and secrets, but does not detail SQL operations or database internals.
Examples
Uses a to-do application, the todo-db service, port mapping, provider configuration, and a PostgreSQL connection secret.
What it assumes
Assumes Docker Compose configuration and introduces the database-service, environment-variable, network, and secret settings needed for the deployment.
What you can do after
Operate/configure a containerized application with PostgreSQL using Docker Compose and verify its running containers.
How it connects
Connects PostgreSQL with Docker Compose, Docker, SQLite, container networking, and secrets management.

Also explained in

Compare how 11 books explain PostgreSQL →

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.