In the previous challenge, you saw that a container's filesystem, made of the read-only image layers and container's very own writable layer, survives container restarts. But what if you don't just restart the container - you need to replace it with another one, using a slightly different configuration? As you also learned, removing a container wipes its filesystem, including all changes made to the writable layer. But can you somehow keep the data written by the application to its filesystem and make it available in the new container?
Volumes to the rescue!

In this challenge, you'll work with the same personal finance tracker you used before.
The app stores its records on disk inside the container at /var/lib/app/ledger.txt
.
Your goal is to start the finance tracker container registry.iximiuz.com/my-finance:v1.0.0
with a volume mounted at the ledger file path, store some financial records using the app's web interface,
and then upgrade the app to use a newer v1.0.1
image,
while preserving the records you added earlier.
1. Run v1.0.0 with a volume mounted at /var/lib/app
Start a container named my-tracker
from registry.iximiuz.com/my-finance:v1.0.0
and mount a storage volume at /var/lib/app
:
Hint: Volumes vs container filesystems 💡
In Docker, volumes are managed by the runtime separately from containers, so when you (implicitly or explicitly) create a volume, its data is backed by a host folder outside the container's writable filesystem layer. It's the simplest way to persist data across container removals and image upgrades. See the Docker volumes documentation for more details.
2. Add a few records via the web UI
Open My Finance (Web UI) to add some financial records:
3. Upgrade to v1.0.1 without losing data (same container name)
Now replace the running app with a newer version registry.iximiuz.com/my-finance:v1.0.1
.
Two conditions must be met:
- The container name must remain the same:
my-tracker
. - The records you added earlier must still be present after the upgrade.
Hint: Replace the container, keep the name, reuse the volume 💡
You'll need to stop and remove the old container to reuse its name for another container with a newer image.
The finance tracker app writes its records to /var/lib/app/ledger.txt
,
which is mounted as a volume.
Because data lives on the volume,
removing the container won't lead to the application data loss.
Starting a new container with the same volume mounted at /var/lib/app
will make the historical
records immediately available.
4. Verify the records are still there
Execute the following command in the container to verify the records are still there:
cat /var/lib/app/ledger.txt
Level up your Server Side game — Join 13,000 engineers who receive insightful learning materials straight to their inbox