Page
Create the container image definition and user files

This lesson will walk you through how to create a Containerfile, or Dockerfile, that defines the contents of the container images.
In this lesson, you will:
- Create a Containerfile, or Dockerfile, that defines the contents of the container images.
Define the image
The container image’s definition is stored in a Containerfile or Dockerfile. The following is an example file that uses a RHEL 9 bootc
image as the base image, and install a web server in the container. A firewall and SSH server are also added to the image for security and management of the server.
Copy the file displayed below into a text file, and name the file rhel9-httpd.txt
.
Containerfile defining the contents of the image rhel9-httpd-v3.txt
.
FROM registry.redhat.io/rhel9/rhel-bootc:9.5-1739775809
RUN <<EOF
set -euox pipefail
#Install firewall, SSH server and web server
dnf install -y firewalld openssh-server httpd
# Use /opt/www/html for web content, which is immutable
sed -i 's/var\/www\/html/opt\/www\/html/g' /etc/httpd/conf/httpd.conf
# Set the SSH and web servers to start at boot
systemctl enable sshd httpd
# Open TCP ports for HTTP and SSH traffic
firewall-offline-cmd --zone=public --add-port=80/tcp
firewall-offline-cmd --zone=public --add-port=22/tcp
EOF
# Copy the website into the documents directory
COPY ./index.html /opt/www/html/index.html
# Run linting as the final step to check for errors
RUN bootc container lint
The container file will also copy a new default HTML page directly to the web server’s document root. Below is the content of my example index.html
file.
<HTML>
<HEAD>
<TITLE>My Application</TITLE>
</HEAD>
<BODY BGCOLOR="000000">
<HR>
<H1><font color="white">The application is running!</font></H1>
<HR>
</BODY>
</HTML>