Grader Labs
← All samples

Run and persist a stateful service through Docker Desktop

DevOpsmacOS5m533 stepsDocker Desktop

Ran and persisted a stateful Postgres service entirely through Docker Desktop — pulled postgres:16, created a named volume, launched a container with a published port and mounted volume, seeded a table over the Exec tab, proved the data survived a restart, then reached it from a second Adminer container over the network.

current trajectory frame

Current operation

Task

Run and persist a stateful service through Docker Desktop

Do everything through the Docker Desktop app — the Images, Volumes, and Containers tabs

and each container's Logs, Files, and Exec tabs. The only step outside Docker

Desktop is opening a browser for Adminer. No docker commands typed in your own shell.

  1. In the Images tab, use Search images (or the Docker Hub search) to find and pull postgres:16 — the specific tag, not latest.
  2. In the Volumes tab, click Create and make a named volume called shopdata.
  3. Back in Images, click Run on postgres:16 and open Optional settings. Set: /var/lib/postgresql/data Then run it. It should appear running in the Containers tab.
    • Container name: shop-db
    • Host port: 5432 (mapped to the container's 5432)
    • Environment variable: POSTGRES_PASSWORD = devpass
    • Volume: mount the shopdata volume at container path
  4. Open the container ▸ Logs tab and confirm Postgres finished starting — look for database system is ready to accept connections.
  5. Switch to the container's Exec tab and start a psql session with psql -U postgres. Type these in by hand (don't paste), confirming each: `sql CREATE TABLE products (id serial primary key, name text, price int); INSERT INTO products (name, price) VALUES ('Mug', 1299), ('Bottle', 1899); SELECT * FROM products; `
  6. Open the container's Files tab and navigate to /var/lib/postgresql/data — the database files stored there are what the shopdata volume is holding onto.
  7. Stop the container, then Start it again from the Containers tab. Re-open Exec ▸ psql and run SELECT * FROM products; — the two rows should still be there. That's the named volume doing its job: the data outlived the container restart.
  8. Now reach the same database from a second container. In Images, search & pull adminer, then Run it with Host port 8080. Open http://localhost:8080 in a browser and log in with System: PostgreSQL, Server: host.docker.internal, Username: postgres, Password: devpass. Open the products table — you should see your two rows, now served to a separate container over the network.

How it's graded

These criteria define the outcome each recording is checked against.