mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-18 02:17:46 +00:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19eb57077f | ||
|
|
1f28c9c144 | ||
|
|
0d6da201b7 | ||
|
|
ecb1256fbb | ||
|
|
afe97c9de5 | ||
|
|
9b6396f6de | ||
|
|
5e58abd8e9 | ||
|
|
3d7340c91c | ||
|
|
1decbd77b5 | ||
|
|
bcc0c63413 | ||
|
|
4a2bc2dded | ||
|
|
fd67e0dff1 | ||
|
|
0fb95ea616 | ||
|
|
e4cf54c166 | ||
|
|
e677d8513b | ||
|
|
d366d4680c | ||
|
|
76337ee326 | ||
|
|
6cd90e4597 | ||
|
|
08ae7a8d23 | ||
|
|
062c62d071 | ||
|
|
13549c2018 | ||
|
|
9094bedfd3 | ||
|
|
0d4eb4365c | ||
|
|
ac77470dee | ||
|
|
ea7a1cd171 | ||
|
|
40910d83b6 | ||
|
|
d7cc363931 | ||
|
|
4f8d6289c2 | ||
|
|
79febc7356 | ||
|
|
8acff25f0d | ||
|
|
2391d6916b |
28
README.md
28
README.md
@@ -1,18 +1,30 @@
|
|||||||
# dockcheck
|
<p align="center">
|
||||||
### A script checking updates for docker images **without pulling** - then selectively auto-update some/all containers.
|
<img src="extras/dockcheck_logo_by_booYah187.png" width="160" title="dockcheck">
|
||||||
|
</p>
|
||||||
|
<p align="center">
|
||||||
|
<img src="https://img.shields.io/badge/-bash-grey?style=flat-square&logo=gnubash" alt="bash">
|
||||||
|
<a href="https://www.gnu.org/licenses/gpl-3.0.html"><img src="https://img.shields.io/badge/license-GPLv3-red?style=flat-square" alt="GPLv3"></a>
|
||||||
|
<img src="https://img.shields.io/github/v/tag/mag37/dockcheck?style=flat-square&label=release" alt="release">
|
||||||
|
<a href="https://ko-fi.com/mag37"><img src="https://img.shields.io/badge/-Ko--fi-grey?style=flat-square&logo=Ko-fi" alt="Buy me a Coffee"></a>
|
||||||
|
<a href="https://liberapay.com/user-bin-rob/donate"><img src="https://img.shields.io/badge/-LiberaPay-grey?style=flat-square&logo=liberapay" alt="LiberaPay"></a>
|
||||||
|
<a href="https://github.com/sponsors/mag37"><img src="https://img.shields.io/badge/-Sponsor-grey?style=flat-square&logo=github" alt="Github Sponsor"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
### :warning: URGENT!
|
<h3 align="center">A script checking updates for docker images <b>without pulling</b><br>Then selectively auto-update containers.</h3>
|
||||||
The 2.0 change had a breaking error - compose-recreation might have included previous containers compose-file.
|
<h4 align="center">With features like excluding specific containers, filter by name, auto-prune dangling images and more.</h4</h3>
|
||||||
If you've had odd errors, you can use the [errorCheck.sh](https://github.com/mag37/dockcheck/blob/main/errorCheck.sh) script to list current running container configs in a readable way. Look especially for **Compose files** listed in wrong places.
|
|
||||||
Recreate the suspicious container(s) manually with `docker compose down && docker compose up -d`.
|
|
||||||
|
### :warning: URGENT! The 2.1 change had a breaking error - make sure you run an updated version.
|
||||||
|
If you've had errors, inspect your containers and look for odd compose paths, volumes or ports.
|
||||||
|
[errorCheck.sh](https://github.com/mag37/dockcheck/blob/main/errorCheck.sh) lists the important bits of each running container. If anything suspicious, recreate the container manually with `docker compose`.
|
||||||
|
|
||||||
### :pushpin: Recent changes:
|
### :pushpin: Recent changes:
|
||||||
|
- **v0.2.3**: Added a self updating function (curl/git) and a ugly changenote-message for updates.
|
||||||
- **v0.2.2**: Fixed breaking errors with multi-compose, odd breakage and working dir error.
|
- **v0.2.2**: Fixed breaking errors with multi-compose, odd breakage and working dir error.
|
||||||
- **v0.2.1**: Added option to exclude a list of containers.
|
- **v0.2.1**: Added option to exclude a list of containers.
|
||||||
- **v0.2.1**: Added multi-compose support (eg. override).
|
- **v0.2.1**: Added multi-compose support (eg. override).
|
||||||
- **v0.2.0**: Fixed error with container:tag definition.
|
- **v0.2.0**: Fixed error with container:tag definition.
|
||||||
- **v0.1.9:** Fixed custom env-support.
|
- **v0.1.9:** Fixed custom env-support.
|
||||||
- **v0.1.8:** Added option to prune dangling images.
|
|
||||||
___
|
___
|
||||||
|
|
||||||
## Dependencies:
|
## Dependencies:
|
||||||
@@ -22,7 +34,7 @@ User will be prompted to download `regctl` if not in `PATH` or `PWD`
|
|||||||
___
|
___
|
||||||
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## `dockcheck.sh`
|
## `dockcheck.sh`
|
||||||
```
|
```
|
||||||
|
|||||||
110
dockcheck.sh
110
dockcheck.sh
@@ -1,10 +1,18 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
VERSION="v0.2.2-URGENT"
|
VERSION="v0.2.3"
|
||||||
|
### ChangeNotes: Added self-updating git/curl-function and a dirty changenote.
|
||||||
Github="https://github.com/mag37/dockcheck"
|
Github="https://github.com/mag37/dockcheck"
|
||||||
|
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
|
||||||
|
|
||||||
|
### Variables for self updating
|
||||||
|
ScriptArgs=( "$@" )
|
||||||
|
ScriptPath="$(readlink -f "$0")"
|
||||||
|
ScriptName="$(basename "$ScriptPath")"
|
||||||
|
ScriptWorkDir="$(dirname "$ScriptPath")"
|
||||||
|
|
||||||
### Check if there's a new release of the script:
|
### Check if there's a new release of the script:
|
||||||
LatestRelease="$(curl -s -r 0-50 https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')"
|
LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')"
|
||||||
[ "$VERSION" != "$LatestRelease" ] && printf "New version available! Latest: %s - Local: %s \nGrab it here: %s \n\n" "$LatestRelease" "$VERSION" "$Github"
|
LatestChanges="$(curl -s -r 0-200 $RawUrl | sed -n "/ChangeNotes/s/### ChangeNotes: //p")"
|
||||||
|
|
||||||
### Help Function:
|
### Help Function:
|
||||||
Help() {
|
Help() {
|
||||||
@@ -32,6 +40,69 @@ while getopts "aynprhe:" options; do
|
|||||||
done
|
done
|
||||||
shift "$((OPTIND-1))"
|
shift "$((OPTIND-1))"
|
||||||
|
|
||||||
|
self_update_git() {
|
||||||
|
cd "$ScriptWorkDir" || { printf "Path error, skipping update.\n" ; return ; }
|
||||||
|
[[ $(builtin type -P git) ]] || { printf "Git not installed, skipping update.\n" ; return ; }
|
||||||
|
ScriptUpstream=$(git rev-parse --abbrev-ref --symbolic-full-name "@{upstream}") || { printf "Script not in git directory, choose a different method.\n" ; self_update_select ; return ; }
|
||||||
|
git fetch
|
||||||
|
[ -n "$(git diff --name-only "$ScriptUpstream" "$ScriptName")" ] && {
|
||||||
|
printf "%s\n" "Pulling the latest version."
|
||||||
|
# git checkout "$ScriptUpstream"
|
||||||
|
git pull --force
|
||||||
|
printf "%s\n" "--- starting over with the updated version ---"
|
||||||
|
cd - || { printf "Path error.\n" ; return ; }
|
||||||
|
exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments
|
||||||
|
exit 1 # exit the old instance
|
||||||
|
}
|
||||||
|
echo "Local is already latest."
|
||||||
|
}
|
||||||
|
self_update_curl() {
|
||||||
|
cp "$ScriptPath" "$ScriptPath".bak
|
||||||
|
if [[ $(builtin type -P curl) ]]; then
|
||||||
|
curl -L $RawUrl > "$ScriptPath" ; chmod +x "$ScriptPath"
|
||||||
|
printf "%s\n" "--- starting over with the updated version ---"
|
||||||
|
exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments
|
||||||
|
exit 1 # exit the old instance
|
||||||
|
else
|
||||||
|
printf "curl not available - download the update manually: %s \n" "$RawUrl"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
self_update_select() {
|
||||||
|
read -r -p "Choose update procedure (or do it manually) - git/curl/[no]: " SelfUpQ
|
||||||
|
if [[ "$SelfUpQ" == "git" ]]; then self_update_git ;
|
||||||
|
elif [[ "$SelfUpQ" == "curl" ]]; then self_update_curl ;
|
||||||
|
else printf "Download it manually from the repo: %s \n\n" "$Github"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
### Choose from list -function:
|
||||||
|
choosecontainers() {
|
||||||
|
while [[ -z "$ChoiceClean" ]]; do
|
||||||
|
read -r -p "Enter number(s) separated by comma, [a] for all - [q] to quit: " Choice
|
||||||
|
if [[ "$Choice" =~ [qQnN] ]] ; then
|
||||||
|
exit 0
|
||||||
|
elif [[ "$Choice" =~ [aAyY] ]] ; then
|
||||||
|
SelectedUpdates=( "${GotUpdates[@]}" )
|
||||||
|
ChoiceClean=${Choice//[,.:;]/ }
|
||||||
|
else
|
||||||
|
ChoiceClean=${Choice//[,.:;]/ }
|
||||||
|
for CC in $ChoiceClean ; do
|
||||||
|
if [[ "$CC" -lt 1 || "$CC" -gt $UpdCount ]] ; then # reset choice if out of bounds
|
||||||
|
echo "Number not in list: $CC" ; unset ChoiceClean ; break 1
|
||||||
|
else
|
||||||
|
SelectedUpdates+=( "${GotUpdates[$CC-1]}" )
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
printf "\nUpdating containers:\n"
|
||||||
|
printf "%s\n" "${SelectedUpdates[@]}"
|
||||||
|
printf "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
### Version check & initiate self update
|
||||||
|
[[ "$VERSION" != "$LatestRelease" ]] && { printf "New version available! Local: %s - Latest: %s \n Change Notes: %s \n" "$VERSION" "$LatestRelease" "$LatestChanges" ; self_update_select ; }
|
||||||
|
|
||||||
### Set $1 to a variable for name filtering later.
|
### Set $1 to a variable for name filtering later.
|
||||||
SearchName="$1"
|
SearchName="$1"
|
||||||
### Create array of excludes
|
### Create array of excludes
|
||||||
@@ -64,10 +135,8 @@ fi
|
|||||||
$regbin version &> /dev/null || { printf "%s\n" "regctl is not working - try to remove it and re-download it, exiting."; exit 1; }
|
$regbin version &> /dev/null || { printf "%s\n" "regctl is not working - try to remove it and re-download it, exiting."; exit 1; }
|
||||||
|
|
||||||
### Check docker compose binary:
|
### Check docker compose binary:
|
||||||
if docker compose version &> /dev/null ; then
|
if docker compose version &> /dev/null ; then DockerBin="docker compose" ;
|
||||||
DockerBin="docker compose"
|
elif docker-compose -v &> /dev/null; then DockerBin="docker-compose" ;
|
||||||
elif docker-compose -v &> /dev/null; then
|
|
||||||
DockerBin="docker-compose"
|
|
||||||
elif docker -v &> /dev/null; then
|
elif docker -v &> /dev/null; then
|
||||||
printf "%s\n" "No docker compose binary available, using plain docker (Not recommended!)"
|
printf "%s\n" "No docker compose binary available, using plain docker (Not recommended!)"
|
||||||
printf "%s\n" "'docker run' will ONLY update images, not the container itself."
|
printf "%s\n" "'docker run' will ONLY update images, not the container itself."
|
||||||
@@ -85,31 +154,6 @@ for i in "${GotUpdates[@]}"; do
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
### Choose from list -function:
|
|
||||||
choosecontainers() {
|
|
||||||
while [[ -z "$ChoiceClean" ]]; do
|
|
||||||
read -r -p "Enter number(s) separated by comma, [a] for all - [q] to quit: " Choice
|
|
||||||
if [[ "$Choice" =~ [qQnN] ]] ; then
|
|
||||||
exit 0
|
|
||||||
elif [[ "$Choice" =~ [aAyY] ]] ; then
|
|
||||||
SelectedUpdates=( "${GotUpdates[@]}" )
|
|
||||||
ChoiceClean=${Choice//[,.:;]/ }
|
|
||||||
else
|
|
||||||
ChoiceClean=${Choice//[,.:;]/ }
|
|
||||||
for CC in $ChoiceClean ; do
|
|
||||||
if [[ "$CC" -lt 1 || "$CC" -gt $UpdCount ]] ; then # reset choice if out of bounds
|
|
||||||
echo "Number not in list: $CC" ; unset ChoiceClean ; break 1
|
|
||||||
else
|
|
||||||
SelectedUpdates+=( "${GotUpdates[$CC-1]}" )
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
printf "\nUpdating containers:\n"
|
|
||||||
printf "%s\n" "${SelectedUpdates[@]}"
|
|
||||||
printf "\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
### Check the image-hash of every running container VS the registry
|
### Check the image-hash of every running container VS the registry
|
||||||
for i in $(docker ps --filter "name=$SearchName" --format '{{.Names}}') ; do
|
for i in $(docker ps --filter "name=$SearchName" --format '{{.Names}}') ; do
|
||||||
[[ " ${Excludes[*]} " =~ ${i} ]] && continue; # Skip if the container is excluded
|
[[ " ${Excludes[*]} " =~ ${i} ]] && continue; # Skip if the container is excluded
|
||||||
@@ -184,7 +228,7 @@ if [ -n "$GotUpdates" ] ; then
|
|||||||
cd "$ContPath" || { echo "Path error - skipping $i" ; continue ; }
|
cd "$ContPath" || { echo "Path error - skipping $i" ; continue ; }
|
||||||
docker pull "$ContImage"
|
docker pull "$ContImage"
|
||||||
### Reformat for multi-compose:
|
### Reformat for multi-compose:
|
||||||
IFS=',' read -r -a Confs <<< "$ContConfigFile" ; unset IFS
|
IFS=',' read -r -a Confs <<< "$ComposeFile" ; unset IFS
|
||||||
for conf in "${Confs[@]}"; do CompleteConfs+="-f $conf " ; done
|
for conf in "${Confs[@]}"; do CompleteConfs+="-f $conf " ; done
|
||||||
|
|
||||||
### Check if the container got an environment file set, use it if so:
|
### Check if the container got an environment file set, use it if so:
|
||||||
|
|||||||
3
errorCheck.sh
Normal file → Executable file
3
errorCheck.sh
Normal file → Executable file
@@ -18,9 +18,10 @@ for i in $(docker ps --filter "name=$SearchName" --format '{{.Names}}') ; do
|
|||||||
echo -e "Service name:\t\t$ContName"
|
echo -e "Service name:\t\t$ContName"
|
||||||
echo -e "Project working dir:\t$ContPath"
|
echo -e "Project working dir:\t$ContPath"
|
||||||
echo -e "Compose files:\t\t$ComposeFile"
|
echo -e "Compose files:\t\t$ComposeFile"
|
||||||
|
echo -e "Environment files:\t$ContEnv"
|
||||||
echo -e "Container image:\t$ContImage"
|
echo -e "Container image:\t$ContImage"
|
||||||
echo
|
echo
|
||||||
echo "Mounts:"
|
echo "Mounts:"
|
||||||
docker inspect -f '{{ range .Mounts }}{{ .Source }}:{{ .Destination }}{{ printf "\n" }}{{ end }}' $i
|
docker inspect -f '{{ range .Mounts }}{{ .Source }}:{{ .Destination }}{{ printf "\n" }}{{ end }}' "$i"
|
||||||
echo
|
echo
|
||||||
done
|
done
|
||||||
|
|||||||
BIN
extras/dockcheck_logo_by_booYah187.png
Normal file
BIN
extras/dockcheck_logo_by_booYah187.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 333 KiB After Width: | Height: | Size: 333 KiB |
1
extras/temp
Normal file
1
extras/temp
Normal file
@@ -0,0 +1 @@
|
|||||||
|
temp
|
||||||
Reference in New Issue
Block a user