Skip to content

Instantly share code, notes, and snippets.

@orimanabu
Last active May 14, 2026 10:38
Show Gist options
  • Select an option

  • Save orimanabu/43197d72509d077a8739af5073bb0082 to your computer and use it in GitHub Desktop.

Select an option

Save orimanabu/43197d72509d077a8739af5073bb0082 to your computer and use it in GitHub Desktop.
Install Podman on Amazon Linux 2023
#!/bin/bash
# To build podman, you have enough resource on the instance.
# I tested this script on t2.xlarge.
topdir=${HOME}/work
mkdir -p ${topdir}
# Install prereq rpms
sudo dnf install -y git golang libseccomp-devel gpgme-devel autoconf automake libtool yajl yajl-devel libcap-devel systemd-devel cni-plugins iptables-nft rpm-build meson golang-github-cpuguy83-md2man.x86_64
# Build podman
echo "=> Building podman..."
cd ${topdir}
git clone https://github.com/containers/podman
cd podman
git switch v4.5
make
sudo make install
# Build conmon
echo "=> Building conmon..."
cd ${topdir}
git clone https://github.com/containers/conmon
cd conmon
make -j
sudo make install
# Build crun
echo "=> Building crun..."
cd ${topdir}
git clone https://github.com/containers/crun
cd crun
./autogen.sh
./configure --prefix=/usr/local
make -j
sudo make install
# Build libslirp
echo "=> Building libslirp..."
cd ${topdir}
git clone https://gitlab.freedesktop.org/slirp/libslirp.git
cd libslirp
git switch stable-4.2
meson build
ninja -C build
sudo ninja -C build install
# Build slirp4netns
echo "=> Building slirp4netns..."
cd ${topdir}
git clone https://github.com/rootless-containers/slirp4netns.git
cd slirp4netns
git switch release/0.4
./autogen.sh
./configure --prefix=/usr/local
make -j
sudo make install
# Install containers-common
echo "=> Building containers-common..."
mkdir ${topdir}/Downloads
cd ${topdir}/Downloads
curl -LO https://ftp.jaist.ac.jp/pub/Linux/Fedora/updates/37/Everything/source/tree/Packages/c/containers-common-1-82.fc37.src.rpm
rpm -ivh ${topdir}/Downloads/containers-common-1-82.fc37.src.rpm
cd ${HOME}/rpmbuild
rpmbuild -bb SPECS/containers-common.spec
sudo dnf install -y RPMS/noarch/containers-common-1-82.amzn2023.noarch.rpm
# Run podman
echo "=> Running podman..."
podman run --rm hello-world
@youwalther65
Copy link
Copy Markdown

@kiprotichgidii
Copy link
Copy Markdown

Thanks for this @orimanabu . For anyone using this rght now, please update the #Install container-common section as follows:

# Install containers-common
echo "=> Building containers-common..."
mkdir ${topdir}/Downloads
cd ${topdir}/Downloads
curl -LO https://download.fedoraproject.org/pub/fedora/linux/updates/41/Everything/source/tree/Packages/c/containers-common-0.64.2-1.fc41.src.rpm
rpm -ivh ${topdir}/Downloads/containers-common-0.64.2-1.fc41.src.rpm

cd ${HOME}/rpmbuild
rpmbuild -bb SPECS/containers-common.spec
sudo dnf install -y RPMS/noarch/containers-common-0.64.2-1.amzn2023.noarch.rpm

@calvinvette
Copy link
Copy Markdown

calvinvette commented Apr 12, 2026

I've updated this a bit for April 2026 - supports Podman 5.8.1 and some other updates and config.
It's a bit of a mess, but handles some things better and fills a few gaps from a fresh AWS Linux 2023.20260406 AMI.
Use at your own risk.

#!/usr/bin/env bash

# To build podman, you have enough resource on the instance.
# I tested this script on t2.xlarge.
PODMAN_VERSION=5.8.1
SLIRP_VERSION=0.4
LIBSLIRP_VERSION="stable-4.2"

# Get the current username
CURRENT_USER=$(whoami)

# Check if the user is missing from either subuid or subgid files
if ! grep -q "^${CURRENT_USER}:" /etc/subuid || ! grep -q "^${CURRENT_USER}:" /etc/subgid; then
    echo "Sub-IDs not fully configured for ${CURRENT_USER}. Updating..."
    sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 "${CURRENT_USER}"
else
    echo "Sub-IDs already configured for ${CURRENT_USER}. No changes needed."
fi


# Install Python 3.12 and Pip if not already present
if ! command -v python3.12 &>/dev/null; then
    echo "Python 3.12 not found. Installing..."
    sudo dnf install -y python3.12 python3.12-pip python3.12-devel
    sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1
else
    echo "Python 3.12 is already installed."
fi

# Update alternatives for pip3
# Note: Ensure the path /usr/bin/pip-3.12 matches your installation (sometimes pip3.12)
if [ -f /usr/bin/pip-3.12 ]; then
    sudo update-alternatives --install /usr/bin/pip3 pip3 /usr/bin/pip-3.12 1
elif [ -f /usr/bin/pip3.12 ]; then
    sudo update-alternatives --install /usr/bin/pip3 pip3 /usr/bin/pip3.12 1
fi

# Install codespell
pip3 install codespell

# Unfortunately we shave to have both Python3.9 for DNF and Pythhon3.12, and changing default Python3 to point to Python3.12 breaks DNF
# First install pip3 for python3.9
sudo dnf install -y python3-pip3
# Next hard-code dnf to use 3.9
sudo sed -i '1s#/usr/bin/python3$#/usr/bin/python3.9#' /usr/bin/dnf


topdir=${HOME}/workspace
mkdir -p ${topdir}

# Install prereq rpms
sudo dnf install -y git golang libseccomp-devel gpgme-devel autoconf automake libtool yajl yajl-devel libcap-devel systemd-devel cni-plugins iptables-nft rpm-build meson golang-github-cpuguy83-md2man

# Build podman
echo "=> Building podman..."
cd ${topdir}
git clone https://github.com/containers/podman
cd podman
git pull
#git switch v${PODMAN_VERSION}
# Checkout by tag, not branch
git checkout v${PODMAN_VERSION}
make
sudo make install

# Build conmon
echo "=> Building conmon..."
cd ${topdir}
git clone https://github.com/containers/conmon
cd conmon
git pull
make -j
sudo make install

# Build crun
echo "=> Building crun..."
cd ${topdir}
git clone https://github.com/containers/crun
cd crun
git pull
./autogen.sh
./configure --prefix=/usr/local
make -j
sudo make install

# Build libslirp
echo "=> Building libslirp..."
cd ${topdir}
git clone https://gitlab.freedesktop.org/slirp/libslirp.git
cd libslirp
git pull
git switch ${LIBSLIRP_VERSION}
meson build
ninja -C build
sudo ninja -C build install

# Build slirp4netns
echo "=> Building slirp4netns..."
cd ${topdir}
git clone https://github.com/rootless-containers/slirp4netns.git
cd slirp4netns
git pull
git switch release/${SLIRP_VERSION}
./autogen.sh
./configure --prefix=/usr/local
make -j
sudo make install

# Install btrfs
# Pre-reqs first
echo "=> Building btrfs support..."
cd ${topdir}
# Sphinx gets installed for Python3.9, which isn't helpful
sudo dnf install -y python3-sphinx e2fsprogs-devel uuid-devel libuuid-devel libblkid-devel libzstd-devel lzo-devel python3-sphinx_rtd_theme python-sphinx_rtd_theme-doc
# Install sphinx and theme for Python 3.9
sudo pip3.9 install sphinx sphinx_rtd_theme
# Install it for our python3.12 too
pip3 install sphinx sphinx_rtd_theme
git clone git://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
cd btrfs-progs
git pull
#git switch release/${BTRFS_VERSION}
./autogen.sh
./configure --prefix=/usr/local
make -j
sudo make install

# Install containers-common
echo "=> Building containers-common..."
mkdir ${topdir}/Downloads
cd ${topdir}/Downloads
# The original version is archived - switching to archive copy, but may need to be updated
# Source version
#curl -LO https://archives.fedoraproject.org/pub/archive/fedora/linux/updates/41/Everything/source/tree/Packages/c/containers-common-0.64.2-1.fc41.src.rpm
#rpm -ivh ${topdir}/Downloads/containers-common-0.64.2-1.fc41.src.rpm
# "binary"
#curl -LO https://archives.fedoraproject.org/pub/archive/fedora/linux/updates/41/Everything/aarch64/Packages/c/containers-common-0.64.2-1.fc41.noarch.rpm       
#rpm -ivh ${topdir}/Downloads/containers-common-0.64.2-1.fc41.noarch.rpm
#curl -LO https://archives.fedoraproject.org/pub/archive/fedora/linux/updates/41/Everything/aarch64/Packages/c/containers-common-extra-0.64.2-1.fc41.noarch.rpm
#rpm -ivh ${topdir}/Downloads/containers-common-extra-0.64.2-1.fc41.noarch.rpm
git clone https://github.com/containers/container-libs.git
cd container-libs
git pull
git checkout ${CONTAINER_LIBS_VERSION}
#./autogen.sh
#./configure --prefix=/usr/local
make -j
sudo make install

# Why is this in ${HOME}?
#mkdir -p ${HOME}/rpmbuild
#cd ${HOME}/rpmbuild
#rpmbuild -bb SPECS/containers-common.spec
#sudo dnf install -y RPMS/noarch/containers-common-1-82.amzn2023.noarch.rpm
#sudo dnf install -y RPMS/noarch/containers-common-0.64.2-1.amzn2023.noarch.rpm

# Install netavark
sudo dnf install -y rust cargo protobuf-devel
git clone https://github.com/containers/netavark.git
cd netavark/
git pull
make -j
sudo make install

# Install pasta (PASST)
git clone git://passt.top/passt
cd passt
make -j
sudo make install


# Update from boltdb to sqlite if necessary
podman system migrate --migrate-db

# Copy a default registries.conf to work with - check if this exists before doing this!
if [ ! -d /etc/containers ]; then
    sudo mkdir -p /etc/containers 
fi
if [ ! -f /etc/containers/registries.conf ]; then
    sudo cp podman/test/registries.conf /etc/containers/
    echo '  "hello-world"="quay.io/podman/hello"' | sudo tee -a /etc/containers/registries.conf
fi
if [ ! -f /etc/containers/policy.json ]; then
    sudo cp podman/test/policy.json /etc/containers
fi

# Run podman
echo "=> Running podman..."
podman run --rm hello-world
# podman run --rm quay.io/podman/hello

@kappa8219
Copy link
Copy Markdown

kappa8219 commented May 14, 2026

I used it to test from inside of AL2023 container:

FROM public.ecr.aws/amazonlinux/amazonlinux:2023

ARG PODMAN_VERSION=5.8.1
ARG SLIRP_VERSION=0.4
ARG LIBSLIRP_VERSION=stable-4.2

ENV BUILDDIR=/build

# Install base build dependencies
RUN dnf install -y \
    git golang libseccomp-devel gpgme-devel autoconf automake libtool \
    yajl yajl-devel libcap-devel systemd-devel cni-plugins iptables-nft \
    rpm-build meson golang-github-cpuguy83-md2man ninja-build \
    python3.12 python3.12-pip python3.12-devel python3-pip \
    rust cargo protobuf-devel \
    python3-sphinx e2fsprogs-devel uuid-devel libuuid-devel \
    libblkid-devel libzstd-devel lzo-devel \
    python3-sphinx_rtd_theme python-sphinx_rtd_theme-doc \
    json-c-devel glib2-devel gcc gcc-c++ make pkgconfig \
    && dnf clean all

# Set up Python 3.12 as default and install pip packages
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1 && \
    pip3.12 install codespell sphinx sphinx_rtd_theme meson && \
    sed -i '1s#/usr/bin/python3$#/usr/bin/python3.9#' /usr/bin/dnf && \
    ln -sf /usr/local/bin/meson /usr/bin/meson

WORKDIR ${BUILDDIR}

RUN git clone https://github.com/containers/conmon && \
    cd conmon && make -j && make install

RUN git clone https://github.com/containers/crun && \
    cd crun && ./autogen.sh && ./configure --prefix=/usr/local && make -j && make install

RUN git clone https://gitlab.freedesktop.org/slirp/libslirp.git && \
    cd libslirp && git checkout ${LIBSLIRP_VERSION} && \
    meson build && ninja -C build && ninja -C build install

RUN git clone https://github.com/rootless-containers/slirp4netns.git && \
    cd slirp4netns && git checkout release/${SLIRP_VERSION} && \
    ./autogen.sh && ./configure --prefix=/usr/local && make -j && make install

RUN git clone git://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git && \
    cd btrfs-progs && ./autogen.sh && ./configure --prefix=/usr/local && make -j && make install

RUN git clone https://github.com/containers/netavark.git && \
    cd netavark && make -j && make install

RUN git clone git://passt.top/passt && \
    cd passt && make -j && make install

# Build podman (last since it's the main target and changes most often)
RUN git clone https://github.com/containers/podman && \
    cd podman && git checkout v${PODMAN_VERSION} && \
    make && make install

# Set up container config files
RUN mkdir -p /etc/containers && \
    cp ${BUILDDIR}/podman/test/registries.conf /etc/containers/registries.conf && \
    echo ' "hello-world"="quay.io/podman/hello"' >> /etc/containers/registries.conf && \
    cp ${BUILDDIR}/podman/test/policy.json /etc/containers/policy.json

# Update ldconfig so libslirp is found
RUN ldconfig

CMD ["podman", "--help"]

With some fixes it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment