Podman Integration for Amazon Linux 2023

The deployment of containerized workloads on Amazon Web Services (AWS) necessitates a robust, scalable, and secure container engine. Amazon Linux serves as the primary operating system for AWS EC2 instances, providing a curated environment optimized for the AWS ecosystem. Within this landscape, Podman has emerged as a critical tool for developers and DevOps engineers. Unlike traditional container engines, Podman offers a daemonless architecture, which fundamentally changes how containers are managed and executed on Amazon Linux 2023.

The transition from legacy container runtimes to Podman on Amazon Linux 2023 is facilitated by the Supplementary Packages for Amazon Linux (SPAL) repository. This repository allows for the seamless installation of Podman, enabling users to leverage high-performance containerization without the overhead of a centralized daemon. The architectural shift provided by Podman is particularly impactful for production workloads on EC2, as it integrates natively with systemd and AWS Elastic Container Registry (ECR). This integration ensures that container lifecycles can be managed as system services, enhancing the stability and observability of the deployment.

When considering the versioning of Amazon Linux, a critical distinction arises between Amazon Linux 2 and Amazon Linux 2023. For those attempting to implement Podman, the choice of operating system is pivotal. Amazon Linux 2 lacks a Podman topic within its Amazon Linux Extras library, which creates a significant barrier for package-manager-based installations. Consequently, Amazon Linux 2023 (AL2023) is the superior and recommended choice for any user seeking to utilize Podman on Amazon Linux. AL2023 not only provides the necessary package availability via SPAL but also offers a modernized kernel and toolset that better supports rootless container execution.

Architectural Foundations and Environment Prerequisites

Before initiating the installation of Podman on an Amazon Linux 2023 instance, specific environmental criteria must be met to ensure a successful deployment. These prerequisites are not merely suggestions but are foundational requirements for the software to interact correctly with the underlying AWS infrastructure.

The primary requirement is an active Amazon Linux 2023 EC2 instance. The choice of AL2023 is mandatory for the package-manager-based installation flow because of the lack of support in the Amazon Linux 2 Extras library. This ensures that the user is working with a system that natively understands the SPAL repository structure.

In addition to the operating system, the user must possess SSH access to the instance. This access must be granted to a user account that holds sudo privileges. Sudo access is non-negotiable during the initial setup phase, as the installation of system-level packages, the modification of sysctl configurations, and the management of user namespaces require administrative authority. Without sudo, the installer cannot modify the /etc/ directory or install packages from the SPAL repository.

Finally, an active internet connection is required. Podman and its dependencies, including the spal-release package and various container images (such as docker.io/library/hello-world or docker.io/library/nginx), must be pulled from remote repositories. An outage or restriction in network connectivity would lead to failure during the dnf install phase.

The following table summarizes the technical prerequisites for the deployment:

Requirement Specification Impact of Absence
Operating System Amazon Linux 2023 (AL2023) Package manager installation failure due to missing Extras topic in AL2
Access Level SSH with sudo privileges Inability to execute dnf commands or modify system configuration files
Network Active Internet Connection Failure to download SPAL release and container images

Package Management and Podman Installation

The installation process on Amazon Linux 2023 is streamlined through the use of the DNF package manager. The process is divided into distinct phases to ensure system stability and the correct application of repositories.

The first step in the sequence is to ensure the system is fully updated. This is achieved through the execution of the following command:

sudo dnf update -y

Updating all packages ensures that the kernel and existing system libraries are at the latest versions, which reduces the likelihood of dependency conflicts during the Podman installation.

Once the system is updated, the user must enable the Supplementary Packages for Amazon Linux (SPAL) repository. Podman is not part of the core AL2023 repository but is provided via SPAL. The repository is enabled by installing the release package:

sudo dnf install -y spal-release

The installation of spal-release adds the necessary metadata to the DNF configuration, allowing the system to locate and retrieve the Podman binaries. After the repository is active, the Podman engine can be installed using the following command:

sudo dnf install -y podman

This command installs the core Podman binaries and the necessary libraries to manage containers. Once the installation is complete, it is necessary to verify that the binaries are correctly placed in the system path and are functioning. This is done using two primary commands. First, to check the specific version of the installed software:

podman --version

Second, to retrieve a detailed overview of the system's container capabilities, including storage drivers and registry configurations:

podman info

Rootless Container Configuration

One of the most significant advantages of Podman is its ability to run containers in rootless mode. Rootless containers improve security by ensuring that the container process does not have root privileges on the host machine, thereby limiting the potential impact of a container escape vulnerability. Achieving this on Amazon Linux 2023 requires specific configuration of user namespaces and UID/GID mappings.

The first technical hurdle is the enablement of user namespaces. This is required to allow non-privileged users to create their own namespaces. The configuration is applied by appending the max user namespace limit to the system configuration:

echo "user.max_user_namespaces=28633" | sudo tee -a /etc/sysctl.d/userns.conf

To ensure the kernel acknowledges this change immediately without requiring a reboot, the configuration must be loaded:

sudo sysctl -p /etc/sysctl.d/userns.conf

Failure to set the user.max_user_namespaces value will result in an error when the user attempts to start a container without root privileges, as the kernel will refuse to allocate the necessary namespace.

Next, the system must be configured to map the user's ID on the host to a range of IDs inside the container. For the default ec2-user on Amazon Linux, the following mappings are applied:

sudo usermod --add-subuids 100000-165535 ec2-user

sudo usermod --add-subgids 100000-165535 ec2-user

These commands assign a range of 65,536 subordinate user and group IDs. This allows the root user inside the container to be mapped to a non-privileged user on the host, effectively isolating the container's privileges. The user can verify these mappings by inspecting the following files:

cat /etc/subuid

cat /etc/subgid

To provide the networking capabilities required for rootless containers, specific helper utilities must be installed. Podman relies on passt and slirp4netns to handle network traffic without requiring root access to the host's network stack:

sudo dnf install -y passt slirp4netns

Once these components are in place, the rootless environment can be tested. A common method is to run the standard "Hello World" image:

podman run --rm docker.io/library/hello-world

The --rm flag ensures that the container is deleted immediately after execution, preventing the accumulation of stopped containers on the EC2 instance.

Docker Compatibility and Socket Integration

For many users, the transition to Podman involves moving from a Docker-based workflow. To maintain compatibility with tools that expect a Docker-daemon-like interface, Podman provides a socket that can be enabled. This allows the Podman engine to listen for API requests in a manner similar to the Docker daemon, but without the permanent background process.

The Podman socket can be enabled for the current user using systemd:

systemctl --user enable --now podman.socket

By utilizing the --user flag, the socket is managed within the user's session rather than as a system-wide root process. This maintains the security posture of the rootless configuration. To verify that the socket is active and listening for requests, the following status command is used:

systemctl --user status podman.socket

With the socket enabled, developers can use various third-party tools that interface with the Docker API, and they will be routed to Podman instead.

Application Deployment and Validation

With the environment fully configured, the final stage is the deployment of a live containerized application. This validates the entire stack, from the SPAL repository and rootless configuration to the network connectivity of the EC2 instance.

A standard deployment involves running a web server, such as Nginx. The following command initiates a detached Nginx container:

podman run -d \ --name web-app \ -p 8080:80 \ docker.io/library/nginx:latest

In this command:
- -d runs the container in the background (detached mode).
- --name web-app assigns a human-readable name to the container for easier management.
- -p 8080:80 maps port 8080 on the EC2 host to port 80 inside the container.

After starting the container, the user should verify its status to ensure it has not crashed or exited:

podman ps

Finally, the application can be tested locally from the EC2 instance using curl:

curl http://localhost:8080

A successful response confirms that the Podman engine is correctly routing traffic from the host to the containerized application. However, it is critical to remember that for external users to access this service, the EC2 security group must be configured to allow inbound traffic on port 8080.

Resource Considerations for Custom Builds

While the package-manager-based installation via SPAL is the recommended path for Amazon Linux 2023, some advanced users may opt to build Podman from source. This path is significantly more resource-intensive and requires a higher tier of EC2 instance to avoid build failures due to memory exhaustion.

Evidence from testing indicates that instances with higher resource allocations, such as the t2.xlarge, are sufficient for building Podman. Users attempting to build from source on smaller instances (e.g., t2.micro or t2.small) may experience crashes or hanging processes during the compilation phase.

Detailed Analysis of Podman on Amazon Linux

The implementation of Podman on Amazon Linux 2023 represents a strategic shift in how containerized workloads are managed on AWS. By moving away from the daemon-centric model of Docker, Podman eliminates a single point of failure. In a traditional Docker setup, if the daemon crashes, all containers managed by that daemon are impacted or become unmanageable. Podman's daemonless architecture ensures that containers are launched as direct children of the process that started them, or managed by systemd.

The integration with systemd is particularly potent. By enabling the Podman socket and utilizing systemd unit files, containers are treated as first-class system citizens. This allows for automated restarts upon failure, dependency mapping between containers, and standardized logging via journald. For production environments on EC2, this means that the reliability of the container is tied to the reliability of the operating system's init system.

The use of the SPAL repository is a key operational detail. It highlights AWS's approach to providing extended functionality without bloating the core image of Amazon Linux 2023. By separating Podman into a supplementary package, AWS allows users to opt into the containerization toolset without forcing it upon every instance. This modularity is essential for maintaining a lean OS footprint, which in turn reduces the attack surface of the instance.

Furthermore, the emphasis on rootless containers addresses the primary security concern in cloud environments: privilege escalation. By utilizing subuid and subgid mappings, Podman creates a highly isolated environment. Even if a vulnerability is exploited within the container, the attacker is mapped to a non-privileged range on the host. This containment strategy is far superior to running containers as root, which is the default in many legacy configurations.

Comparing Amazon Linux 2 and Amazon Linux 2023 reveals the evolution of the AWS ecosystem. The absence of a Podman topic in the Amazon Linux 2 Extras library serves as a clear signal that AL2023 is the intended platform for modern container orchestration. The move to AL2023 is not just about package availability but about the underlying support for the technologies that make Podman viable, such as improved user namespace support in the kernel.

In conclusion, the deployment of Podman on Amazon Linux 2023 via SPAL provides a secure, efficient, and production-ready environment. The combination of daemonless architecture, rootless execution, and systemd integration makes it a superior choice for running containers on EC2 instances.

Sources

  1. GitHub - oneuptime/blog
  2. OneUptime Blog
  3. GitHub Gist - orimanabu

Related Posts