Install docker script

This commit is contained in:
Fabio Sinibaldi 2025-02-25 15:31:20 +01:00
parent 64efd981e6
commit 82806d7433
1 changed files with 40 additions and 0 deletions

40
utils/install_docker.sh Normal file
View File

@ -0,0 +1,40 @@
#! /usr/bin/bash
echo "Installing denpendency packages..."
sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common lsb-release
echo "Installing docker key..."
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker-archive-keyring.gpg
echo "Adding docker repository.."
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
echo "Refreshing packages.."
sudo apt update
echo "NB Check if installing from Docker repo instead of Ubuntu repo"
apt-cache policy docker-ce
# Check repo
read -p "Are we installing from Docker repo? (Y/N): " repo_ok
if [[ $repo_ok == [nN] || $repo_ok == [nN][oO] ]]; then
echo "Exiting, check repo config.."
exit 1
fi
echo "Installing docker Community Edition"
sudo apt install docker-ce
echo "Docker status : "
systemctl status docker
#Add user to docker group
read -p "Do you want to add the current user to docker group? (Y/N): " add_user
if [[ $add_user == [yY] || $add_user == [yY][eE][sS] ]]; then
sudo newgrp docker
sudo usermod -aG docker ${USER}
echo "User added to docker group"
fi
echo "Process finished"