Add update-docker-and-docker-compose scripts

This commit is contained in:
Christopher
2024-04-08 17:44:40 -05:00
parent f2c9401144
commit 744be7c4dc
2 changed files with 66 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
# Run command
```bash
bash -c "$(wget -qLO - https://raw.githubusercontent.com/bigbeartechworld/big-bear-scripts/master/update-docker-and-docker-compose/run.sh)"
```
# Can't Resolve Domain
To resolve this issue, please follow these steps:
1. Copy the contents of run.sh from this repository.
2. Create a file named run.sh on your server.
3. Execute the following command on your server:
```bash
bash run.sh
```

View File

@@ -0,0 +1,49 @@
#!/bin/bash
# Function to remove standalone Docker Compose if it exists
remove_standalone_docker_compose() {
if command -v docker-compose &>/dev/null; then
echo "docker-compose found. Checking installation method..."
# Check if docker-compose was installed via apt-get
if dpkg -l | grep -qw docker-compose; then
echo "docker-compose was installed via apt-get. Removing..."
sudo apt-get remove -y docker-compose
else
echo "docker-compose was not installed via apt-get. Removing binary..."
sudo rm $(which docker-compose)
fi
else
echo "docker-compose not found. Skipping removal..."
fi
}
# Update the system and install Docker if not already installed
update_and_install_docker() {
echo "Updating system packages..."
sudo apt-get update
echo "Installing or Updating Docker..."
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
echo "Ensuring Docker starts on boot..."
sudo systemctl enable docker
echo "Starting Docker service..."
sudo systemctl start docker
}
# Main function to orchestrate updates
main() {
remove_standalone_docker_compose
update_and_install_docker
# Verifying the installation
echo "Verifying Docker and Docker Compose versions..."
docker --version
docker compose version
}
# Execute the main function
main