Ajouter install_docker.sh

This commit is contained in:
guillaume 2023-10-20 17:30:11 +02:00
parent 038a6bf49f
commit 680bd6f46c

60
install_docker.sh Normal file
View File

@ -0,0 +1,60 @@
#!/bin/bash
# Define colors
GREEN="\e[32m"
CYAN="\e[36m"
RESET="\e[0m"
clear
echo -e "${CYAN}Step 1: Add Docker's official GPG key${RESET}"
sudo apt-get update
echo -e "${GREEN}Updating package list${RESET}"
sleep 2
sudo apt-get install ca-certificates curl gnupg
echo -e "${GREEN}Installing required packages: ca-certificates, curl, gnupg${RESET}"
sleep 2
sudo install -m 0755 -d /etc/apt/keyrings
echo -e "${GREEN}Creating directory /etc/apt/keyrings${RESET}"
sleep 2
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo -e "${GREEN}Downloading Docker's GPG key and saving it to /etc/apt/keyrings/docker.gpg${RESET}"
sleep 2
clear
echo -e "${CYAN}Step 2: Add the repository to Apt sources${RESET}"
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
echo -e "${GREEN}Adding the Docker repository to Apt sources${RESET}"
sleep 2
sudo apt-get update
echo -e "${GREEN}Updating package list with Docker repository${RESET}"
sleep 2
clear
echo -e "${CYAN}Step 3: Install Docker${RESET}"
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
echo -e "${GREEN}Installing Docker and related packages${RESET}"
sleep 2
sudo adduser $USER docker
echo -e "${GREEN}Added $USER to Docker group${RESET}"
sleep 2
clear
echo -e "${CYAN}Step 4: Verify Docker Installation${RESET}"
sudo docker run hello-world
echo -e "${GREEN}Running a test container to verify Docker installation${RESET}"
echo -e "${CYAN}Docker installation and verification complete.${RESET}"