Last active
May 9, 2025 09:51
-
-
Save habibimustafa/bce4683528cd20daf4f040ccd193cb1c to your computer and use it in GitHub Desktop.
Podman with Youki Installer Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
# Podman + youki Installer for Ubuntu 22.04 | |
# Version: 1.2 | |
# Features: | |
# - Installs latest Podman with Kubic repo | |
# - Installs youki OCI runtime | |
# - Configures Podman to use youki by default | |
# - Verifies installation with test container | |
# Check for root privileges | |
if [ "$EUID" -ne 0 ]; then | |
echo "❌ Please run as root/sudo" | |
exit 1 | |
fi | |
# Setup colored output | |
COLOR_RESET='\033[0m' | |
COLOR_GREEN='\033[0;32m' | |
COLOR_CYAN='\033[0;36m' | |
status_msg() { | |
echo -e "${COLOR_CYAN}[+]${COLOR_RESET} $1" | |
} | |
success_msg() { | |
echo -e "${COLOR_GREEN}[✓]${COLOR_RESET} $1" | |
} | |
status_msg "Adding Podman repository..." | |
KUBIC_KEY="/etc/apt/trusted.gpg.d/kubic.gpg" | |
KUBIC_SOURCE="/etc/apt/sources.list.d/kubic.sources" | |
# Download and install repository key | |
curl -fsSL "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_22.04/Release.key" \ | |
| gpg --dearmor | tee "$KUBIC_KEY" >/dev/null | |
# Create source file with signed-by reference | |
cat <<EOF | tee "$KUBIC_SOURCE" >/dev/null | |
Types: deb | |
URIs: https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_22.04/ | |
Suites: . | |
Components: . | |
Signed-By: $KUBIC_KEY | |
EOF | |
# Update system packages | |
status_msg "Updating system packages..." | |
apt-get update -qq | |
# Install base dependencies | |
status_msg "Installing dependencies..." | |
apt-get install -y -qq \ | |
curl \ | |
wget \ | |
crun \ | |
uidmap \ | |
btrfs-progs \ | |
libseccomp2 \ | |
conmon \ | |
containernetworking-plugins | |
# Install Podman | |
status_msg "Installing Podman..." | |
apt-get install -y -qq podman | |
# Install youki from pre-built binary | |
status_msg "Installing youki..." | |
YOUKI_VERSION="v0.5.3" | |
YOUKI_URL="https://github.com/youki-dev/youki/releases/download/${YOUKI_VERSION}/youki-${YOUKI_VERSION#v}-x86_64-gnu.tar.gz" | |
# Download and install | |
wget "$YOUKI_URL" -O /tmp/youki.tar.gz | |
tar -xzf /tmp/youki.tar.gz -C /usr/local/bin youki | |
chmod +x /usr/local/bin/youki | |
rm /tmp/youki.tar.gz | |
# Configure youki as default runtime | |
status_msg "Configuring Podman..." | |
mkdir -p /etc/containers | |
cat <<EOF > /etc/containers/containers.conf | |
[engine] | |
runtime = "youki" | |
[engine.runtimes] | |
youki = ["/usr/local/bin/youki"] | |
EOF | |
# Verify installation | |
status_msg "Verifying installation..." | |
if ! command -v podman &>/dev/null; then | |
echo "❌ Podman installation failed!" | |
exit 1 | |
fi | |
if ! command -v youki &>/dev/null; then | |
echo "❌ youki installation failed!" | |
exit 1 | |
fi | |
success_msg "Base installation completed" | |
# Test container execution | |
status_msg "Running test container..." | |
if podman run --rm hello-world | grep -q "Hello from Docker!"; then | |
success_msg "Podman with youki is working!" | |
else | |
echo "❌ Container test failed!" | |
exit 1 | |
fi | |
# Post-install instructions | |
echo -e "\n${COLOR_GREEN}Installation successful!${COLOR_RESET}" | |
echo "To use Podman as non-root user:" | |
echo "1. Create user namespace:" | |
echo " sudo touch /etc/subuid /etc/subgid" | |
echo " sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 \$(whoami)" | |
echo "2. Relogin to apply changes" | |
echo "3. Test with: podman run --rm hello-world" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment