Compare commits

..

5 Commits

Author SHA1 Message Date
mag37
132fda3388 Update README.md 2023-08-29 20:42:00 +02:00
mag37
cc9b3b0828 Update README.md 2023-08-28 21:31:18 +02:00
mag37
29c2c5e961 Merge pull request #41 from elchanly/elchanly-patch-1
Update dockcheck.sh to include stopped containers
2023-08-28 21:26:12 +02:00
mag37
5dc9af9874 Update dockcheck.sh
Did some changes to the logic, cleaned some whitespace.
2023-08-28 21:24:23 +02:00
elchanly
f91ca08d54 Update dockcheck.sh to include stopped containers
as suggested in reddit, this is proposed to include stopped containers
take into account im not skilled in this programming language but i wanted to contribute.
2023-08-21 23:56:03 +02:00
2 changed files with 11 additions and 5 deletions

View File

@@ -16,6 +16,7 @@
### :pushpin: Recent changes: ### :pushpin: Recent changes:
- **v0.2.5**: Added a new option `-s` to include stopped containers in the check for updates.
- **v0.2.4**: Fixed a bug with the Exclude-logic to only exclude exact matches. Added a counter. - **v0.2.4**: Fixed a bug with the Exclude-logic to only exclude exact matches. Added a counter.
- **v0.2.3**: Added a self updating function (curl/git) and a ugly changenote-message for updates. - **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.
@@ -47,6 +48,7 @@ Options:
-e Exclude containers, separated by comma. -e Exclude containers, separated by comma.
-p Auto-Prune dangling images after update. -p Auto-Prune dangling images after update.
-r Allow updating images for docker run, wont update the container. -r Allow updating images for docker run, wont update the container.
-s Include stopped containers in the check. (Logic: docker ps -a).
``` ```
Basic example: Basic example:
@@ -76,8 +78,9 @@ After the updates are complete, you'll get prompted if you'd like to prune dangl
Containers need to be manually stopped, removed and created again to run on the new image. Containers need to be manually stopped, removed and created again to run on the new image.
### :hammer: Known issues ### :hammer: Known issues
- No detailed error feedback (just skip + list what's skipped) . - No detailed error feedback (just skip + list what's skipped).
- Not respecting `--profile` options when re-creating the container. - Not respecting `--profile` options when re-creating the container.
- Not working well with containers created by Portainer.
## `dc_brief.sh` ## `dc_brief.sh`
Just a brief, slimmed down version of the script to only print what containers got updates, no updates or errors. Just a brief, slimmed down version of the script to only print what containers got updates, no updates or errors.

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VERSION="v0.2.4" VERSION="v0.2.5"
### ChangeNotes: Fixes to the Exclude-option to only exclude exact matches. +cleaning ### ChangeNotes: Added an -s option to include stopped contianers in the check.
Github="https://github.com/mag37/dockcheck" Github="https://github.com/mag37/dockcheck"
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
@@ -26,15 +26,18 @@ Help() {
echo "-e Exclude containers, separated by comma." echo "-e Exclude containers, separated by comma."
echo "-p Auto-Prune dangling images after update." echo "-p Auto-Prune dangling images after update."
echo "-r Allow updating images for docker run, wont update the container" echo "-r Allow updating images for docker run, wont update the container"
echo "-s Include stopped containers in the check. (Logic: docker ps -a)"
} }
while getopts "aynprhe:" options; do Stopped=""
while getopts "aynprhse:" options; do
case "${options}" in case "${options}" in
a|y) UpdYes="yes" ;; a|y) UpdYes="yes" ;;
n) UpdYes="no" ;; n) UpdYes="no" ;;
r) DrUp="yes" ;; r) DrUp="yes" ;;
p) PruneQ="yes" ;; p) PruneQ="yes" ;;
e) Exclude=${OPTARG} ;; e) Exclude=${OPTARG} ;;
s) Stopped="-a" ;;
h|*) Help ; exit 0 ;; h|*) Help ; exit 0 ;;
esac esac
done done
@@ -162,7 +165,7 @@ if [[ -n ${Excludes[*]} ]] ; then
fi fi
### 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 $Stopped --filter "name=$SearchName" --format '{{.Names}}') ; do
### Looping every item over the list of excluded names and skipping: ### Looping every item over the list of excluded names and skipping:
for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done
printf ". " printf ". "