Persist data and connect Docker containers

8 steps · about 2 h 50 min · Intermediate

  1. See why container data disappears (guide, Docker, 15 min)

    Understand the writable layer's lifetime before deciding where real data should live.

  2. Store data in named volumes (doc, Docker, 30 min)

    Create, inspect, mount and back up volumes, the default choice for databases in containers.

  3. Mount host folders for development (doc, Docker, 20 min)

    Use bind mounts for live code editing and learn the read-only flag and permission pitfalls.

  4. Keep scratch data in memory (doc, Docker, 10 min)

    Know when temporary or sensitive files should never touch disk at all.

  5. Learn Docker's networking model (doc, Docker, 25 min)

    Map how containers get addresses, publish ports and resolve each other's names.

  6. Use user-defined bridge networks (doc, Docker, 20 min)

    See why a custom bridge beats the default one for name resolution and isolation.

  7. Wire containers together by hand (tutorial, Docker, 30 min)

    Practise attaching, inspecting and disconnecting containers so the network behaviour is concrete.

  8. Declare networks in Compose (guide, Docker, 20 min)

    Finish by splitting front-end and back-end networks in one Compose file so the database is not reachable from everything.