Why Start by Hand
From the next module on, Terraform creates and changes Docker objects for you.
Before that, you will create the same kind of objects by hand, once. You will
then know what each object is, how to check it with the docker command, and
what doing everything by hand is like. Those same commands are how you will
check Terraform's work later.
Five kinds of object matter in this course: images, containers, networks, volumes and published ports.

Read the diagram from the top. The image (top right) is the template; the green arrow shows a container being created from it. Your terminal (top left) reaches the container through a published port. Inside the network, a second container reaches the first by name. Below, a volume holds data that does not belong to any one container. The sections below explain each part.
Images and Containers
An image is a read-only template: a program plus everything it needs to
run. It is named repository:tag. The course's practice app is the image
hashicorp/http-echo:1.0: a tiny web server that replies to every request
with a fixed piece of text. The tag 1.0 pins the version. A tag such as
latest can point to a different image tomorrow, so the course always names
an exact tag.
A container is a program running from an image, with its own name, ID,
settings and writable files. Many containers can run from one image. The
http-echo program takes its settings as arguments: -text sets the reply,
and it listens on port 5678 unless told otherwise.
Docker can change only a few settings of an existing container, such as its restart policy and memory limit. Most others, including its command and published ports, are fixed when the container is created. Changing them means removing the container and creating a new one. You will see the consequence in Terraform's plans, which often propose replacing a container rather than updating it.
Networks: How Containers Find Each Other
A network connects containers. On a network you create yourself (a
user-defined network), Docker lets containers reach each other by name:
a container on the network tfp-handmade-net can call
http://tfp-handmade-app:5678/. Containers on Docker's built-in default
network can reach each other only by IP address, which changes when a
container is recreated. That is why every practice stack creates its own
network.
Published Ports: Reaching a Container From Your Computer
A container's port is not reachable from your computer until you publish
it. The option -p 127.0.0.1:18080:5678 connects port 18080 on your computer
to port 5678 inside the container. Read it as host address : host port :
container port.
The 127.0.0.1 part matters. Without an address, Docker publishes the port on
all of your computer's network addresses, so other devices on the same network
can reach it too; Docker's own documentation calls this insecure by default.
With 127.0.0.1, only your computer can. Every exercise in the course
includes it.
Only one container can publish a given host port at a time. A second attempt
fails with port is already allocated.
Volumes: What Survives a Container
When you remove a container, its own writable files are deleted with it. A
volume is named storage that Docker manages separately. You mount it into a
container at a path, such as /data, and it keeps its contents when the
container is removed, until you remove the volume itself.
Inspecting What Exists
| Command | Shows |
|---|---|
docker ps | Running containers |
docker ps -a | All containers, including stopped ones |
docker ps --filter name=tfp- | Containers whose name contains tfp- |
docker port <name> | The container's published ports |
docker network ls, docker volume ls | Networks and volumes, with the same --filter |
docker logs <name> | What the container has printed |
docker inspect <name> | Every detail, as JSON |
What Local Practice Cannot Show
Docker gives Terraform real objects to manage, but it is not a cloud provider. It has no cloud-style identity and permission system, no regions or availability zones, no quotas or request limits, no slow provisioning and no bill. Cloud providers also have far more kinds of resource, each with its own rules about what can change in place.
What transfers unchanged is the Terraform part: the language, plans, state, modules, environments, refactoring, tests and the team workflow. When you work with a cloud provider later, you add that provider's own rules and costs to the same skills.
Exercise: Build It by Hand
You will create a network, a volume and the practice app by hand, check each one, change the app's message, and clean everything up.
Starting state: the toolchain from the previous lesson. Port 18080 must be
free; curl http://127.0.0.1:18080/ should fail to connect before you start.
Run everything in a normal terminal; no folder is needed.
-
Create a network and a volume:
docker network create tfp-handmade-net docker volume create tfp-handmade-dataDocker prints the network's ID and the volume's name.
-
Start the app on that network, publishing port 5678 as 18080 on your computer only:
docker run -d --name tfp-handmade-app --network tfp-handmade-net -p 127.0.0.1:18080:5678 hashicorp/http-echo:1.0 -text="hello from a hand-made container"-druns the container in the background,--namegives it a fixed name and--networkattaches it. Everything after the image name is passed to the app: here, the reply text. Docker downloads the image the first time, then prints the new container's ID. -
Check it from your computer:
curl http://127.0.0.1:18080/ docker ps --filter name=tfp- docker port tfp-handmade-appcurlprintshello from a hand-made container. Illustrative output from the other two commands:CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 8701488333db hashicorp/http-echo:1.0 "/http-echo '-text=h…" 2 seconds ago Up 1 second 127.0.0.1:18080->5678/tcp tfp-handmade-app 5678/tcp -> 127.0.0.1:18080The ID and times differ on your computer. Check the PORTS column:
127.0.0.1:18080->5678/tcpmeans port 18080 on your computer leads to port 5678 in the container. -
Reach the app by name from another container on the same network:
docker run --rm --network tfp-handmade-net nginx:1.30-alpine wget -qO- http://tfp-handmade-app:5678/This starts a short-lived container from the
nginx:1.30-alpineimage, which you will use later as a proxy. Here only itswgettool is used, a simple web client likecurl. It prints the app's reply, and--rmremoves the helper container when it finishes. -
Read the app's log:
docker logs tfp-handmade-appIllustrative output:
2026/10/11 08:49:51 [INFO] server is listening on :5678 2026/10/11 08:49:52 127.0.0.1:18080 172.18.0.1:47082 "GET / HTTP/1.1" 200 33 "curl/8.18.0" 10.031µs 2026/10/11 08:50:01 tfp-handmade-app:5678 172.18.0.3:32990 "GET / HTTP/1.1" 200 33 "Wget" 6.207µsThere is one line per request: the address used,
200for success, and the client,curlorWget. Times, addresses and version numbers vary. -
Store data in the volume, then read it from a brand-new container:
docker run --rm -v tfp-handmade-data:/data nginx:1.30-alpine sh -c 'echo "kept in a volume" > /data/note.txt' docker run --rm -v tfp-handmade-data:/data nginx:1.30-alpine cat /data/note.txt-v tfp-handmade-data:/datamounts the volume at/data. The first container writes a file there and is removed; the second, a different container, printskept in a volume. -
Change the app's message. A container's command cannot be edited, so you remove the container and start a new one:
docker rm -f tfp-handmade-app docker run -d --name tfp-handmade-app --network tfp-handmade-net -p 127.0.0.1:18080:5678 hashicorp/http-echo:1.0 -text="a new message" curl http://127.0.0.1:18080/docker rm -fstops and removes the container in one step.curlnow printsa new message. Notice what you had to remember: the old name, network, port and image, typed again exactly. Terraform will keep that description for you. -
Clean up. First list what you created, then remove it:
docker ps -a --filter name=tfp-handmade docker network ls --filter name=tfp-handmade docker volume ls --filter name=tfp-handmade docker rm -f tfp-handmade-app docker network rm tfp-handmade-net docker volume rm tfp-handmade-dataRun the three list commands again: each now shows only its heading line.
Success: curl returned both messages in turn, the helper container
reached the app by name, the volume kept its file between two different
containers, and nothing named tfp-handmade remains.
If something differs:
| What you see | Likely cause | Next step |
|---|---|---|
Bind for 127.0.0.1:18080 failed: port is already allocated | Another container already publishes 18080 | Find it with docker ps. If it is an earlier tfp- container, remove it. Docker still created the new container without starting it: remove it with docker rm tfp-handmade-app before retrying |
Conflict. The container name "/tfp-handmade-app" is already in use | A container from an earlier attempt still exists | docker rm -f tfp-handmade-app, then repeat the step |
network with name tfp-handmade-net already exists | The network is left from an earlier attempt | Carry on; it is the same network |
wget: bad address 'tfp-handmade-app:5678' | The helper container is not on the network, or the name is mistyped | Check --network tfp-handmade-net and the spelling |
curl fails just after the container starts | The app has not started listening yet | Wait a second and repeat |
error while removing network: network tfp-handmade-net has active endpoints | A container is still attached | Remove the container first, then the network |
volume is in use | A container still uses the volume | Remove that container first, then the volume |
Independent task: start a container that writes one file into the volume's
/data folder and one into its own /tmp folder, then remove it. Before you
check, predict which file a new container can still read. Use this setup,
which recreates the volume you just removed:
docker volume create tfp-handmade-data
docker run --name tfp-handmade-temp -v tfp-handmade-data:/data nginx:1.30-alpine sh -c 'echo "in the volume" > /data/a.txt; echo "in the container" > /tmp/b.txt'
docker rm tfp-handmade-temp
Then check with cat in new containers, as in step 6, and remove the volume
when you have finished.
Check Your Understanding
- Why does changing the app's reply text need a new container?
- Two containers are on different networks you created. Can one reach the other by name? What would you change so that it can?
- Why does every exercise publish ports on
127.0.0.1? - Name two things a cloud provider has that this local practice cannot show you, and one Terraform skill that transfers unchanged.
Answer and Reasoning
Independent task
Only /data/a.txt survives. It was written to the volume, which still exists
after the container is removed:
docker run --rm -v tfp-handmade-data:/data nginx:1.30-alpine cat /data/a.txt
That prints in the volume. The file in /tmp belonged to the removed
container's own writable files, which were deleted with it. A new container
starts from the image again, so this fails with No such file or directory:
docker run --rm nginx:1.30-alpine cat /tmp/b.txt
Remove the volume afterwards with docker volume rm tfp-handmade-data.
Understanding check
- The reply text is part of the container's command, which is fixed when the container is created. The only way to change it is to remove the container and create a new one with the new text.
- No. Name lookup works only between containers on the same user-defined network. Attach both containers to one network you created, and each can then call the other by name.
- A port published without an address is reachable from other devices on
your network.
127.0.0.1keeps the practice apps reachable only from your own computer. - Any two of: an identity and permission system, regions and availability zones, quotas and request limits, slow provisioning, costs. Transferable skills include reading plans, managing state, writing modules, refactoring, testing and reviewing changes.