#!/bin/bash
#Nifty: Install latest docker community engine

curl -s https://nifty.sh/lib/universal/niftylib.sh > /tmp/lib.nifty.sh
. /tmp/lib.nifty.sh
rm -f /tmp/lib.nifty.sh

# Requirements
require_root
require_64bit
require_os alma9 alma10

ce "Updating system packages"
dnf clean all
dnf update -y

ce "Adding docker repo"
dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo

ce "Installing docker"
dnf install -y docker-ce docker-ce-cli containerd.io

ce "Configuring docker daemon"
mkdir -p /etc/docker
cat - > /etc/docker/daemon.json <<EOF
{
	"data-root": "/data/docker"
}
EOF

ce "Enabling and starting docker"
systemctl enable docker
systemctl start docker
