mirror of
https://github.com/bigbeartechworld/big-bear-scripts.git
synced 2026-03-31 06:24:02 -04:00
Add install-docker script
This commit is contained in:
9
install-docker/README.md
Normal file
9
install-docker/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
## Why?
|
||||
|
||||
This script is a handy script to install Docker on Ubuntu or Debian. Also it checks for docker installed with snap and asks if you want to uninstall it.
|
||||
|
||||
## How to use?
|
||||
|
||||
```bash
|
||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/bigbeartechworld/big-bear-scripts/master/install-docker/run.sh)"
|
||||
```
|
||||
62
install-docker/run.sh
Normal file
62
install-docker/run.sh
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to ask for user confirmation
|
||||
confirm() {
|
||||
while true; do
|
||||
read -rp "$1 [y/n]: " yn
|
||||
case $yn in
|
||||
[Yy]*) return 0 ;;
|
||||
[Nn]*) return 1 ;;
|
||||
*) echo "Please answer yes or no." ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# Check if Docker is installed via Snap
|
||||
if snap list docker &> /dev/null; then
|
||||
echo "Docker is installed via Snap."
|
||||
if confirm "Do you want to uninstall the Snap version of Docker?"; then
|
||||
echo "Uninstalling Docker from Snap..."
|
||||
sudo snap remove docker
|
||||
else
|
||||
echo "Skipping Docker uninstallation from Snap."
|
||||
fi
|
||||
else
|
||||
echo "Docker is not installed via Snap, or Snap is not installed."
|
||||
fi
|
||||
|
||||
# Update package database
|
||||
echo "Updating package database..."
|
||||
sudo apt-get update
|
||||
|
||||
# Install prerequisites
|
||||
echo "Installing prerequisites..."
|
||||
sudo apt-get install -y \
|
||||
apt-transport-https \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg \
|
||||
lsb-release
|
||||
|
||||
# Add Docker's official GPG key
|
||||
echo "Adding Docker's official GPG key..."
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
||||
|
||||
# Set up the stable repository
|
||||
echo "Setting up Docker repository..."
|
||||
DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
|
||||
CODENAME=$(lsb_release -cs)
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/$DISTRO \
|
||||
$CODENAME stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
|
||||
# Install Docker Engine
|
||||
echo "Installing Docker Engine..."
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
|
||||
|
||||
# Verify Docker installation
|
||||
echo "Verifying Docker installation..."
|
||||
sudo docker run hello-world
|
||||
|
||||
echo "Docker installation completed successfully!"
|
||||
Reference in New Issue
Block a user