Skip to content
Ameen Abozaid
Planned lessonJNR-049-L05

Volumes and networks

  • Lesson 5 of 8
  • Junior
On This Lesson 4 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

keep data and connect containers.

Planned topics

  • A volume is storage managed by Docker that outlives the container: -v pgdata:/var/lib/postgresql/data.
  • A bind mount maps a host folder; volumes are better for databases.
  • On a user-defined network, containers reach each other by name: the app connects to host db, not localhost.
  • The default bridge network does not give name lookup.
  • Create with docker network create shop-net and --network shop-net.
Draft outline details

Demonstration

bash
docker network create shop-net
docker run -d --name db --network shop-net -v pgdata:/var/lib/postgresql/data -e POSTGRES_PASSWORD=dev postgres:16

Check your understanding

What hostname does the app use to reach the container named db?

Show answer

db, on a shared user-defined network.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.