Free lesson · Module 1, lesson 7 of 7

It runs on my laptop: the notice board in one command

Start the notice board and its database with one command, post and list a notice with curl, and say why "it runs on my laptop" is where DevOps starts.

Lessons in this module

Lesson notes

For the student

A service is a program that keeps running and answers on a port. The notice board is two of them, an API and a PostgreSQL database, each in its own container, started together by Docker Compose with one command. Work in ~/cloud-devops.

The stack

  • api: the notice board, on localhost:8000
  • db: PostgreSQL 18.7, published only on 127.0.0.1:55432, for tools on your laptop; the API reaches it as db:5432
  • quickstart/compose.yaml starts both, the database first; make up runs it
  • .env holds your settings: make up copies it from .env.example the first time, and it is never committed. The notices password in it is a harmless value for a database on your own laptop

The run

  • make up: builds, starts db and api, waits until both are healthy, loads the 12 seed notices (the first time takes a few minutes for downloads)
  • make ps: db and api both up and (healthy)
  • curl -s localhost:8000/health prints {"status":"ok","database":"ok"}
  • curl -s -X POST localhost:8000/notices -d @labs/m01/notice.json -H 'content-type: application/json' answers 201 with your notice, id 13: "Library reading room hours", open 8 am to 10 pm from 30 November to 19 December 2026
  • curl -s localhost:8000/notices | jq length prints 13: 12 seed notices and yours
  • {"status":"degraded","database":"down"} (503) means the API runs but cannot reach the database: make ps, then make logs
  • Without the content-type header the POST answers 422, and its detail reads Input should be a valid dictionary or object to extract fields from: the body was not read as JSON

Every day

  • make up again skips seed notices already there; make logs follows the API's log lines; make down stops the stack and keeps the data
  • When something fails, make ps first

Why it matters

  • The same image, the same pinned versions (postgres:18.7, python:3.14.10-slim) and the same setting names (.env.example) make it run the same on every laptop. Running on yours is the first proof; the rest of the course carries it to every other machine

Try it

  • Post the library notice, list the notices, and fetch localhost:8000/notices/13
  • Then run bash labs/m01/check.sh
  • You should see notice 13's JSON and OK health

Lesson quiz

Checked in your browser. Nothing is sent or saved.

5 questions

Question 1 · easy

What is a service, as this lesson defines it?

Question 2 · medium

make up loaded the 12 seed notices. Priya posts two notices of her own, then runs curl -s localhost:8000/notices | jq length. What prints?

Question 3 · medium

curl -s localhost:8000/health prints {"status":"degraded","database":"down"}. Which part is broken?

Question 4 · medium

Asha posts labs/m01/notice.json without the content-type header. The board answers 422, and the detail reads Input should be a valid dictionary or object to extract fields from. What is the fix?

Question 5 · hard

Arjun has the project too. What makes it run the same on his laptop as on Sameer's?

Setting up: Linux or WSL2, Docker and Git on an 8 GB laptopThat was the free module. Tell me when the course opens