DevOPS/Script/docker_install.sh

50 lines
1.9 KiB
Bash
Raw Normal View History

#!/bin/bash
# Mettre à jour les paquets
echo "Mise à jour des paquets..."
sudo apt update -y
sudo apt upgrade -y
# Installation de Docker
echo "Installation de Docker..."
sudo apt install -y ca-certificates curl gnupg lsb-release
# Ajouter la clé GPG officielle de Docker
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# Ajouter le dépôt Docker
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Installation de Docker Engine
echo "Installation de Docker Engine..."
sudo apt update -y
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
# Vérification de l'installation de Docker
echo "Vérification de Docker..."
sudo systemctl enable docker
sudo systemctl start docker
sudo docker --version
# Installation de Docker Compose (standalone)
echo "Installation de Docker Compose..."
DOCKER_COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep -Po '"tag_name": "\K.*?(?=")')
sudo curl -L "https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
# Installation de Portainer
echo "Installation de Portainer..."
sudo docker volume create portainer_data
sudo docker run -d -p 8000:8000 -p 9443:9443 \
--name=portainer --restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce:latest
echo "Installation terminée ! Docker, Docker Compose et Portainer sont maintenant installés."
echo "Accédez à Portainer via https://votre_ip:9443 pour l'interface de gestion."