Exercise: Storage and Snapshots
Comparing VM and Container Snapshots
1 Purpose
This exercise demonstrates the different approaches to “snapshotting” in traditional virtualization versus containerization. You will create a point-in-time snapshot of a virtual machine’s disk and memory state. Then, you will “snapshot” a container by committing its changes to a new, reusable image. This highlights the philosophical difference between stateful, persistent VMs and stateless, ephemeral containers.
2 What You’ll Accomplish
By the end of this exercise, you will be able to:
- Create a snapshot of a VM using
virt-manager. - Use
podman committo create a new image from a container’s changes. - Explain the conceptual difference between a VM snapshot and a container image.
This exercise maps to the following program and course learning outcomes:
- Course Learning Outcomes (CLOs):
- 1. Identify hardware and basic network components: This exercise covers the management of virtual storage components (virtual disks and container images).
This exercise develops the following skills, which align with the O*NET SOC Code 15-1232.00 for Computer User Support Specialists.
| Learning Objective | O*NET KSAs | Technologies Used |
|---|---|---|
| Create a VM snapshot. | Knowledge: Computers & Electronics Skills: None |
virt-manager |
| Create a container image from a container. | Knowledge: Computers & Electronics Skills: None |
podman commit |
3 Prerequisites
This exercise requires: - A running Fedora 42 VM (your main exercise environment). - A virtual machine created in virt-manager (from Exercise 9.1). It does not need to be running.
4 Step-by-Step Guide
4.1 Part 1: Virtual Machine Snapshot
A VM snapshot saves the entire state of a virtual machine at a specific moment in time—including the contents of its memory (if running) and the exact state of its virtual hard disk.
- Open
virt-managerand ensure your VM from Exercise 9.1 is selected. - Open the Snapshots View: With the VM selected, click the “View” menu, then “Snapshots”.
- Create a New Snapshot: Click the “Create new snapshot” button (a plus icon) in the bottom left.
- Name the snapshot
Before-Updatesand provide a simple description like “Clean install state.” - Click “Finish”.
- A new snapshot will appear in the list. You can now make changes to your VM (like installing software), and if something goes wrong, you can select this snapshot and click “Apply” to revert the entire machine to this exact saved state.
4.2 Part 2: Container “Snapshot” (Image Commit)
Containers are typically stateless, meaning changes made inside them are lost when the container is removed. To “save” the state of a container, you don’t snapshot the running instance; instead, you commit its changes to a new, reusable image.
Start a Basic Container: We will start a basic
alpinecontainer and give it a name.podman run -d --name=my-test-container docker.io/library/alpine sleep 3600Make a Change: Use
podman execto create a new file inside the running container. This is our “change.”podman exec my-test-container touch /hello-from-chuck.txtCommit the Change to a New Image: The
podman commitcommand takes the current state of the container’s filesystem and saves it as a new image.podman commit my-test-container my-new-alpine-imageVerify the New Image: List your local Podman images. You will see your new image in the list.
podman imagesYou can now run a new container from
my-new-alpine-image, and it will already contain the/hello-from-chuck.txtfile. You have created a new, reusable blueprint from your changes.
4.3 Part 3: Understand the Difference
- The VM snapshot saved the live state of a specific, running machine. It’s a backup and a restore point.
- The container commit created a new, stateless template (image) from the changes made in a container. It’s a way to create a new version of a blueprint.
4.4 Step 4: Clean Up
Stop and remove the test container.
podman stop my-test-container podman rm my-test-containerRemove the new image you created.
podman rmi my-new-alpine-image
5 Reflect and Review
Now that you have completed this exercise, reflect on your experience in your Microsoft Teams Student Notebook:
- 3 commands or actions you took in this exercise.
- 2 technologies you used (
virt-manager,podman). - 1 question you still have about the difference between an image and a snapshot.
Answer these questions in your notebook to solidify your understanding:
- What is the primary purpose of taking a snapshot of a VM?
- What does the
podman commitcommand produce as its output? - If you take a VM snapshot while the VM is running, what additional information is saved compared to a snapshot of a powered-off VM?
- Why is “committing an image” a more natural fit for the container philosophy than taking a live snapshot of a running container?