39 lines
820 B
Bash
39 lines
820 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
set -e
|
||
|
|
||
|
for compose_file in /opt/docker/**/docker-compose.yml; do
|
||
|
if [[ $(docker compose -f "$compose_file" ps -q) ]]; then
|
||
|
echo "> Updating $compose_file"
|
||
|
docker compose -f "$compose_file" pull
|
||
|
docker compose -f "$compose_file" up -d --remove-orphans
|
||
|
echo ""
|
||
|
else
|
||
|
echo "> Skipping $compose_file as it's not running."
|
||
|
echo ""
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
echo "> Containers have been updated."
|
||
|
echo ""
|
||
|
|
||
|
confirm=n
|
||
|
read -p "
|
||
|
> Do you want to prune docker? [y/N]
|
||
|
> WARNING! This will remove:
|
||
|
> - all stopped containers
|
||
|
> - all networks not used by at least one container
|
||
|
> - all dangling images
|
||
|
> - unused build cache
|
||
|
" confirm
|
||
|
echo ""
|
||
|
|
||
|
if [[ $confirm == [yY] ]]; then
|
||
|
docker system prune -f -a
|
||
|
echo "> Docker has been pruned."
|
||
|
else
|
||
|
echo "> Nothing has been changed."
|
||
|
fi
|
||
|
|
||
|
exit
|