Add update-docker.sh
This commit is contained in:
33
update-docker.sh
Normal file
33
update-docker.sh
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Starting system update and Docker maintenance..."
|
||||||
|
|
||||||
|
# Update and upgrade APT packages
|
||||||
|
echo "Running apt update & upgrade..."
|
||||||
|
apt update
|
||||||
|
apt upgrade -y
|
||||||
|
|
||||||
|
# Pull latest images, stop containers, and recreate in detached mode
|
||||||
|
echo "Pulling latest Docker images..."
|
||||||
|
docker compose pull
|
||||||
|
|
||||||
|
echo "Stopping and removing existing containers..."
|
||||||
|
docker compose down
|
||||||
|
|
||||||
|
echo "Starting containers in detached mode..."
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
# Prune unused Docker objects
|
||||||
|
echo "Pruning unused Docker objects..."
|
||||||
|
docker system prune -a -f
|
||||||
|
|
||||||
|
# Show running containers
|
||||||
|
echo "Current running Docker containers:"
|
||||||
|
docker ps
|
||||||
|
|
||||||
|
echo "Maintenance complete."
|
||||||
|
|
||||||
|
echo "Removing the file"
|
||||||
|
rm -f ./update-docker.sh
|
||||||
|
|
||||||
|
echo "Done!"
|
||||||
Reference in New Issue
Block a user