Skip to content

Instantly share code, notes, and snippets.

@iversond
Created October 31, 2023 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iversond/2a786efb80c06b77903b8e8eb217c26e to your computer and use it in GitHub Desktop.
Save iversond/2a786efb80c06b77903b8e8eb217c26e to your computer and use it in GitHub Desktop.
Script to install and configure rootless Podman on OEL 8
#! /bin/bash
function echoinfo() {
local GC="\033[1;32m"
local EC="\033[0m"
printf "${GC} ☆ INFO${EC}: %s${GC}\n${EC}" "$@";
}
function echoerror() {
local RC="\033[1;31m"
local EC="\033[0m"
printf "${RC} ✖ ERROR${EC}: %s\n${EC}" "$@" 1>&2;
}
echoinfo "Install and configure rootless podman"
sudo dnf module enable -y container-tools:ol8 1>/dev/null
sudo dnf module install -y container-tools:ol8 1>/dev/null
sudo dnf install -y podman-docker podman-plugins 1>/dev/null
sudo podman system info --runtime=crun 1>/dev/null
mkdir -p $HOME/.config/containers/
tee $HOME/.config/containers/storage.conf 1>/dev/null << EOF
[storage]
driver = "overlay"
[storage.options.overlay]
mount_program = "/usr/bin/fuse-overlayfs"
EOF
sleep 2
echoinfo "Update OS Params for Opensearch"
echo "user.max_user_namespaces=28633" | sudo tee -a /etc/sysctl.d/userns.conf 1>/dev/null
sudo sysctl -p /etc/sysctl.d/userns.conf 1>/dev/null
echo "vm.max_map_count=262144" | sudo tee -a /etc/sysctl.conf 1>/dev/null
sudo sysctl -p /etc/sysctl.conf 1>/dev/null
sleep 2
echoinfo "Add docker.io to Registry"
echo 'unqualified-search-registries = ["docker.io"]' | sudo tee -a /etc/containers/registries.conf 1>/dev/null
sleep 2
echoinfo "Enable linger for opc user processes"
sudo loginctl enable-linger "$(whoami)"
sleep 2
echoinfo "Configure profile for podman socket"
echo "export XDG_RUNTIME_DIR=/run/user/$(id -u)" | tee -a $HOME/.bash_profile 1>/dev/null
echo "export DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock" | tee -a $HOME/.bash_profile 1>/dev/null
sleep 2
echoinfo "Configure profile for podman aliases"
echo "alias podman=\"sudo /usr/bin/podman\"" | tee -a $HOME/.bash_profile 1>/dev/null
echo "alias docker=\"sudo /usr/bin/podman\"" | tee -a $HOME/.bash_profile 1>/dev/null
source $HOME/.bash_profile 1>/dev/null
sleep 2
echoinfo "Start podman"
systemctl --user enable podman.socket > /dev/null 2>&1
systemctl --user start podman.socket > /dev/null 2>&1
sleep 2
echoinfo "Test if podman is running"
status=$(curl -s -H "Content-Type: application/json" --unix-socket /run/user/$UID/podman/podman.sock http://localhost/_ping)
case $status in
'OK' )
echoinfo "Podman is running"
;;
* )
echoerror "Podman is not running"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment