Typorithm · medium

Volumes & Networks

volumes-networksdevopsvolumenetworkpersistence
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn Volumes & Networks

0%

Containers

Volumes persist data beyond a container's lifecycle — named volumes are managed by Docker. A user-defined network lets containers reach each other by name through Docker's built-in DNS, which is how multi-container apps communicate.

Containers are ephemeral, so any data written inside them is lost on removal. Volumes fix that: named volumes are managed by Docker and outlive the container, while bind mounts map a host path into the container.

docker run -v data:/var/lib/db mounts the named volume 'data' at the database's data directory, so the data persists across restarts and re-creations.

A user-defined network created with docker network create lets containers find each other by name. Joining with --network appnet --name api means another container on appnet can connect to 'api' via Docker's DNS — the basis of multi-container apps.

01

Volumes persist data beyond a container's lifecycle.

02

Named volumes are managed by Docker; bind mounts use a host path.

03

User-defined networks give containers DNS by name.

docker volume create data
docker run -v data:/var/lib/db postgres
docker network create appnet
docker run --network appnet --name api myapp

Read the implementation

Connect each part of the code to the concept before you type.

1. Create a volume

docker volume create makes a named volume that Docker manages and persists.

docker volume create data

2. Mount a volume

-v mounts the named volume 'data' at /var/lib/db so the database survives container restarts.

docker run -v data:/var/lib/db postgres

3. Create a network

docker network create makes a user-defined network containers can join.

docker network create appnet

4. Join a network

--network attaches the container to appnet so others can reach it as 'api' via Docker's DNS.

docker run --network appnet --name api myapp

5. DNS name

On a user-defined network the container name becomes its DNS hostname.

--name api

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

Volumes & Networks: Lesson & Practice · Typorithm | ApplyDjinn