100% found this document useful (2 votes)
3K views5 pages

EX188 Podman Practice Notes

The document provides comprehensive notes for the EX188 practice exercise on container management using Podman, detailing the steps to containerize a static website with Apache and a Java application. It includes a full question statement, step-by-step solutions, and additional notes on commands and practices. The exercise emphasizes building custom images, managing container lifecycles, and verifying web access.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
3K views5 pages

EX188 Podman Practice Notes

The document provides comprehensive notes for the EX188 practice exercise on container management using Podman, detailing the steps to containerize a static website with Apache and a Java application. It includes a full question statement, step-by-step solutions, and additional notes on commands and practices. The exercise emphasizes building custom images, managing container lifecycles, and verifying web access.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Absolutely!

Below is a complete, well-organized set of notes for the EX188 practice


exercise on container management using Podman, including the full question
statement and the step-by-step solution — ideal for study or revision.

📘 EX188 Practice Notes: Container Management with Podman

🧾 Practice Question Statement


You are a system administrator working with containers using Podman on a RHEL system (or
compatible environment). Your task is to containerize a simple static website using Apache
(httpd) and manage the container lifecycle as described below.
🔧 Perform the following:
1. Create a custom container image using the ubi8 base image.
2. Install the httpd web server in the image.
3. Create a static HTML file at /var/www/html/[Link] with the exact content:
Welcome to EX188 Practice
4. Configure the image so that the container runs the Apache web server in the
foreground.
5. Tag the image as webserver:v1.
6. Run a container using this image:
o Name it ex188-web
o Run it in detached mode
o Expose container port 80 and map it to host port 8080
7. Verify that the container is running and the web page is accessible via curl.
8. Commit the running container into a new image tagged webserver:v2.
9. Stop and remove the container.

✅ Step-by-Step Solution is as follows


🔹 Step 1: Create a working directory
mkdir ex188-webserver
cd ex188-webserver
🔹 Step 2: Create the Containerfile
Creates a container file similar to Docker file: touch Containerfile
Edit it using your preferred editor (e.g., vim, nano, or code): vim Containerfile

Paste the following content:


FROM [Link]/ubi8/ubi
RUN dnf install -y httpd && \
mkdir -p /var/www/html && \
echo "Welcome to EX188 Practice" > /var/www/html/[Link] && \
dnf clean all
EXPOSE 80
CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]
Explanation:
 dnf install -y httpd: Installs Apache web server
 mkdir -p /var/www/html: Creates the default web root
 echo ... > /var/www/html/[Link]: Adds static content
 dnf clean all: Reduces image size
 CMD [...]: Starts Apache in foreground mode when the container runs
🔹 Step 3: Build the container image
podman build -t webserver:v1 .
 -t webserver:v1: Tags the image as webserver:v1
 .: Uses the current directory as build context
🔹 Step 4: Run the container
podman run -dit --name ex188-web -p 8080:80 webserver:v1
 -d: Detached (runs in background)
 -i: Interactive (needed for -t)
 -t: Allocates pseudo-TTY
 --name: Names the container
 -p [Link] Maps host port 8080 to container port 80

🔹 Step 5: Verify the container and webpage


Check if the container is running: podman ps
Verify the web page using curl: curl [Link]
Expected output: Welcome to EX188 Practice
🔹 Step 6: Commit the container to a new image
podman commit ex188-web webserver:v2
 This saves the container’s current state into a new image tagged webserver:v2

🔹 Step 7: Stop and remove the container


podman stop ex188-web
podman rm ex188-web
🧠 Additional Notes
Common vim Commands:

Action Command

Insert mode I

Save and exit :wq

Exit without saving :q!

Podman image list: podman images


Remove an image: podman rmi webserver:v1
✅ Summary
By following this exercise, you have:
 Built a custom image with Apache from ubi8
 Served a static web page
 Ran a container with port mapping
 Verified web access using curl
 Committed a running container into a new versioned image
 Practiced container lifecycle management with Podman.
🧾 EX188 Practice Question #2: Containerizing a Python Flask App
🧩 Scenario:
You're a container administrator working on deploying a small Python web application using
Podman. Your task is to containerize the app using UBI8 and manage it using best practices.

🔧 Tasks:

1. Create a simple Java application named [Link] that prints the following text
to standard output:

Hello from EX188 Java Sample!

2. Write a Containerfile to:


o Use the ubi8/openjdk-11 image as the base.
o Copy your Java source file into the container.
o Compile the Java file during the image build.
o Expose port 8080 (optional, for consistency — Java programs usually run on
8080 if networked).
o Set the container to automatically run the compiled Java program when started.
3. Build the container image and tag it as javaapp:v1.
4. Run a container from the image using:
o Name: ex188-java
o Detached mode
o Map host port 8080 to container port 8080 (optional, since it’s a console
app)
5. Verify the output by checking the container logs or attaching to it:

podman logs ex188-java


6. Commit the running container to a new image tagged javaapp:v2.
7. Stop and remove the container.

Perfect! Here's the complete solution to your EX188-style Java container question — now
including all required Linux commands to create files, build images, run containers, and
manage everything step by step.
✅ EX188 Practice: Containerizing a Java App with Podman solution
🧩 STEP 1: Create Project Directory
mkdir ex188-java
cd ex188-java
📝 STEP 2: Create the Java File
nano [Link]
Paste the following content:
public class Sample {
public static void main(String[] args) {
[Link]("Hello from EX188 Java Sample!");
}
}
👉 Press Ctrl + O to save, Enter to confirm, and Ctrl + X to exit.

📄 STEP 3: Create the Containerfile


nano Containerfile
Paste the following content:
FROM [Link]/ubi8/openjdk-11
COPY [Link] .
RUN javac [Link]
EXPOSE 8080
CMD ["java", "Sample"]
👉 Save and exit: Ctrl + O, Enter, then Ctrl + X.

🔧 STEP 4: Build the Container Image


podman build -t javaapp:v1 .
✅ This creates an image named javaapp with tag v1.

🚀 STEP 5: Run the Container


podman run -dit --name ex188-java -p 8080:8080 javaapp:v1
 -d → detached mode
 -i → interactive
 -t → allocates a pseudo-TTY
 --name ex188-java → gives the container a name
 -p 8080:8080 → optional port mapping (not required for this app, but included for
consistency)
🔍 STEP 6: View Container Output
podman logs ex188-java
✅ Output should be:
Hello from EX188 Java Sample!
🧱 STEP 7: Commit the Container to a New Image
podman commit ex188-java javaapp:v2
✅ Now you have a new image javaapp:v2.
🛑 STEP 8: Stop and Remove the Container
podman stop ex188-java
podman rm ex188-java
📦 STEP 9: View Images
podman images
You should see both versions:
REPOSITORY TAG IMAGE ID CREATED SIZE
javaapp v1 abcdef123456 5 minutes ago ...
javaapp v2 defabc654321 Just now ...
🧩 Difference Between nano and touch commands:

Feature Nano Touch

Creates an empty file or updates


📄 Purpose Opens a file editor
timestamp

Used for Writing/editing file content Creating files quickly (blank)

💻 Interactive? Yes — it's a text editor No — runs instantly and exits

Yes — you type and save


🔤 Adds content? No — file remains empty
content

🧑‍💻 Example use nano [Link] touch [Link]

📌 Common use Editing code, configs, scripts Creating placeholder files

You might also like