mirror of
https://github.com/bigbeartechworld/big-bear-scripts.git
synced 2026-06-03 05:32:11 -04:00
Add update-docker-and-docker-compose scripts
This commit is contained in:
17
update-docker-and-docker-compose/README.md
Normal file
17
update-docker-and-docker-compose/README.md
Normal 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
|
||||
```
|
||||
49
update-docker-and-docker-compose/run.sh
Normal file
49
update-docker-and-docker-compose/run.sh
Normal 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
|
||||
Reference in New Issue
Block a user