Volumes and networks
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, notlocalhost. - The default bridge network does not give name lookup.
- Create with
docker network create shop-netand--network shop-net.
Draft outline details
Demonstration
docker network create shop-net
docker run -d --name db --network shop-net -v pgdata:/var/lib/postgresql/data -e POSTGRES_PASSWORD=dev postgres:16Check 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.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.