Exercise: OCI Application Container with Podman
Running Your First Rootless Container
1 Purpose
This exercise introduces you to the basics of running an OCI-compliant application container using Podman, the default container engine on modern Fedora systems. You will run a simple “hello-world” container and then a more practical web server container, all without requiring root privileges. This demonstrates the power and security benefits of modern, rootless container workflows.
2 What You’ll Accomplish
By the end of this exercise, you will be able to:
- Use the
podman runcommand to execute a container from an image. - Explain the purpose of the
--rm,-it, and-pflags. - Run a containerized web server and access it from your host machine.
- Use
podman psto view running containers.
This exercise maps to the following program and course learning outcomes:
- Course Learning Outcomes (CLOs):
- 1. Identify hardware and basic network components: This exercise introduces containers, a modern method of virtualizing and deploying software components.
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 |
|---|---|---|
| Run a rootless OCI application container. | Knowledge: Computers & Electronics Skills: None |
Podman, OCI |
Explain basic podman run command options. |
Knowledge: Computers & Electronics Skills: Reading Comprehension |
podman run |
3 Prerequisites
This exercise requires a running Fedora 42 virtual machine with internet access. Podman is installed by default on Fedora Workstation.
4 Step-by-Step Guide
Open a terminal window in your Fedora VM to begin.
4.1 Step 1: Run the “Hello World” Container
The hello-world image is a tiny container designed to test that your container engine is working correctly.
Run the following command. Note that
sudois not required.podman run --rm -it hello-worldAnalyze the Command and Output:
podman run: The basic command to run a container. Podman will first check if you have thehello-worldimage locally. If not, it will automatically download it from a container registry.--rm: This flag tells Podman to automatically remove the container after it exits. This is useful for keeping your system clean during tests.-it: A combination of-i(interactive) and-t(pseudo-TTY), which allows you to interact with the container.- The output will be a message from the container explaining that your installation appears to be working correctly.
4.2 Step 2: Run a Web Server Container
Now let’s run a more useful container: the official Apache HTTPD web server.
Run the following command:
podman run -d --rm -p 8080:80 docker.io/library/httpdAnalyze the Command:
-d: This flag runs the container in “detached” mode (in the background) and prints the new container’s ID.-p 8080:80: This is the port mapping flag. It maps port8080on your Fedora host to port80inside the container. This allows you to access the web server running inside the container.
4.3 Step 3: View the Running Container
You can see a list of your running containers with the podman ps command.
Run the command:
podman psYou will see your
httpdcontainer listed, along with its ID, the image it’s from, and the port mapping.
4.4 Step 4: Access the Web Server
Because you mapped port 8080, you can now access the web server from your Fedora VM’s browser.
- Open the Firefox browser in your VM.
- Navigate to the address:
http://localhost:8080 - You should see a simple page with the text: “It works!”. This page is being served by the Apache server running inside your container.
4.5 Step 5: Stop the Container
Find your container’s ID or name from the
podman pscommand.Use the
podman stopcommand to stop it.# Replace with your container's ID or name podman stop <container_id>Because you used the
--rmflag when you started it, Podman will automatically remove the stopped container. Runningpodman psagain will show an empty list.
5 Reflect and Review
Now that you have completed this exercise, reflect on your experience in your Microsoft Teams Student Notebook:
- 3
podmansubcommands you used (e.g., run, ps, stop). - 2 command-line flags you learned about.
- 1 question you still have about rootless containers.
Answer these questions in your notebook to solidify your understanding:
- What is the benefit of running Podman commands without
sudo? - What does the
-p 8080:80flag do in apodman runcommand? - What command would you use to see a list of your currently running containers?
- What does the
--rmflag accomplish?