1. Create a volume
docker volume create makes a named volume that Docker manages and persists.
docker volume create dataTyporithm · medium
Step 1 of 8 · intro card
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.
Volumes persist data beyond a container's lifecycle.
Named volumes are managed by Docker; bind mounts use a host path.
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 myappConnect each part of the code to the concept before you type.
docker volume create makes a named volume that Docker manages and persists.
docker volume create data-v mounts the named volume 'data' at /var/lib/db so the database survives container restarts.
docker run -v data:/var/lib/db postgresdocker network create makes a user-defined network containers can join.
docker network create appnet--network attaches the container to appnet so others can reach it as 'api' via Docker's DNS.
docker run --network appnet --name api myappOn a user-defined network the container name becomes its DNS hostname.
--name apiRead the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.