mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-18 10:27:54 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6e2d50949 | ||
|
|
432edbfa75 | ||
|
|
f233cf3b41 | ||
|
|
7630a95442 | ||
|
|
c7304093bd | ||
|
|
d877a86292 | ||
|
|
191d27097d | ||
|
|
4ddb54770e | ||
|
|
c50312dc83 | ||
|
|
c47c703ce9 | ||
|
|
372e79a12c | ||
|
|
5c2cf75b21 |
14
README.md
14
README.md
@@ -1,5 +1,11 @@
|
|||||||
# dockcheck
|
# dockcheck
|
||||||
### A script checking updates for docker images **without pulling** - then selectively auto-update some/all containers.
|
### A script checking updates for docker images **without pulling** - then selectively auto-update some/all containers.
|
||||||
|
### :pushpin: Recent changes:
|
||||||
|
- **v0.2.1**: Added option to exclude a list of containers.
|
||||||
|
- **v0.2.1**: Added multi-compose support (eg. override).
|
||||||
|
- **v0.2.0**: Fixed error with container:tag definition.
|
||||||
|
- **v0.1.9:** Fixed custom env-support.
|
||||||
|
- **v0.1.8:** Added option to prune dangling images.
|
||||||
___
|
___
|
||||||
|
|
||||||
## Dependencies:
|
## Dependencies:
|
||||||
@@ -15,13 +21,14 @@ ___
|
|||||||
```
|
```
|
||||||
$ ./dockcheck.sh -h
|
$ ./dockcheck.sh -h
|
||||||
Syntax: dockcheck.sh [OPTION] [part of name to filter]
|
Syntax: dockcheck.sh [OPTION] [part of name to filter]
|
||||||
Example: dockcheck.sh -a ng
|
Example: dockcheck.sh -a -e nextcloud,heimdall
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h Print this Help.
|
-h Print this Help.
|
||||||
-a|y Automatic updates, without interaction.
|
-a|y Automatic updates, without interaction.
|
||||||
-n No updates, only checking availability.
|
-n No updates, only checking availability.
|
||||||
-p Auto-Prune dangling images after update.
|
-p Auto-Prune dangling images after update.
|
||||||
|
-e Exclude containers, separated by comma.
|
||||||
-r Allow updating images for docker run, wont update the container.
|
-r Allow updating images for docker run, wont update the container.
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -67,10 +74,13 @@ Containers need to be manually stopped, removed and created again to run on the
|
|||||||
- ~~Using relative paths for volumes eg. `${PWD}/data:data` will create the volumes where you stand.~~
|
- ~~Using relative paths for volumes eg. `${PWD}/data:data` will create the volumes where you stand.~~
|
||||||
- ~~Having no curl/wget leads to corrupt `regctl` without alerting.~~
|
- ~~Having no curl/wget leads to corrupt `regctl` without alerting.~~
|
||||||
- ~~Using custom `.env` files does not work.~~
|
- ~~Using custom `.env` files does not work.~~
|
||||||
|
- ~~Pull not respecting image:tags, always defaulting to latest~~
|
||||||
|
- ~~Not respecting multi-compose projects using multiple `-f` like `...override.yml` or similar.~~
|
||||||
|
- ~~Not being able to exclude specific containers.~~
|
||||||
|
|
||||||
### :hammer: Known issues
|
### :hammer: Known issues
|
||||||
- ~~No granular choice of what to update (except initial name filter).~~
|
|
||||||
- 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.
|
||||||
|
|
||||||
## `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.
|
||||||
|
|||||||
15
dc_brief.sh
Normal file → Executable file
15
dc_brief.sh
Normal file → Executable file
@@ -1,8 +1,22 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
### If not in PATH, set full path. Else just "regctl"
|
### If not in PATH, set full path. Else just "regctl"
|
||||||
regbin="regctl"
|
regbin="regctl"
|
||||||
|
### options to allow exclude:
|
||||||
|
while getopts "e:" options; do
|
||||||
|
case "${options}" in
|
||||||
|
e) Exclude=${OPTARG} ;;
|
||||||
|
*) exit 0 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift "$((OPTIND-1))"
|
||||||
|
### Create array of excludes
|
||||||
|
IFS=',' read -r -a Excludes <<< "$Exclude" ; unset IFS
|
||||||
|
|
||||||
SearchName="$1"
|
SearchName="$1"
|
||||||
|
|
||||||
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
|
||||||
printf ". "
|
printf ". "
|
||||||
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
||||||
LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}')
|
LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}')
|
||||||
@@ -34,3 +48,4 @@ if [[ -n ${GotUpdates[*]} ]] ; then
|
|||||||
printf "\n\033[0;33mContainers with updates available:\033[0m\n"
|
printf "\n\033[0;33mContainers with updates available:\033[0m\n"
|
||||||
printf "%s\n" "${GotUpdates[@]}"
|
printf "%s\n" "${GotUpdates[@]}"
|
||||||
fi
|
fi
|
||||||
|
printf "\n\n"
|
||||||
|
|||||||
19
dockcheck.sh
19
dockcheck.sh
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
VERSION="v0.1.9"
|
VERSION="v0.2.1"
|
||||||
Github="https://github.com/mag37/dockcheck"
|
Github="https://github.com/mag37/dockcheck"
|
||||||
|
|
||||||
### Check if there's a new release of the script:
|
### Check if there's a new release of the script:
|
||||||
@@ -9,22 +9,24 @@ LatestRelease="$(curl -s -r 0-50 https://raw.githubusercontent.com/mag37/dockche
|
|||||||
### Help Function:
|
### Help Function:
|
||||||
Help() {
|
Help() {
|
||||||
echo "Syntax: dockcheck.sh [OPTION] [part of name to filter]"
|
echo "Syntax: dockcheck.sh [OPTION] [part of name to filter]"
|
||||||
echo "Example: dockcheck.sh -a ng"
|
echo "Example: dockcheck.sh -a -e nextcloud,heimdall"
|
||||||
echo
|
echo
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo "-h Print this Help."
|
echo "-h Print this Help."
|
||||||
echo "-a|y Automatic updates, without interaction."
|
echo "-a|y Automatic updates, without interaction."
|
||||||
echo "-n No updates, only checking availability."
|
echo "-n No updates, only checking availability."
|
||||||
|
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"
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts "aynprh" options; do
|
while getopts "aynprhe:" 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} ;;
|
||||||
h|*) Help ; exit 0 ;;
|
h|*) Help ; exit 0 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -32,6 +34,8 @@ shift "$((OPTIND-1))"
|
|||||||
|
|
||||||
### 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
|
||||||
|
IFS=',' read -r -a Excludes <<< "$Exclude" ; unset IFS
|
||||||
|
|
||||||
### Check if required binary exists in PATH or directory:
|
### Check if required binary exists in PATH or directory:
|
||||||
if [[ $(builtin type -P "regctl") ]]; then regbin="regctl" ;
|
if [[ $(builtin type -P "regctl") ]]; then regbin="regctl" ;
|
||||||
@@ -108,6 +112,7 @@ choosecontainers() {
|
|||||||
|
|
||||||
### 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
|
||||||
printf ". "
|
printf ". "
|
||||||
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
||||||
LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}')
|
LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}')
|
||||||
@@ -177,11 +182,15 @@ if [ -n "$GotUpdates" ] ; then
|
|||||||
### cd to the compose-file directory to account for people who use relative volumes, eg - ${PWD}/data:data
|
### cd to the compose-file directory to account for people who use relative volumes, eg - ${PWD}/data:data
|
||||||
cd "$(dirname "${ComposeFile}")" || { echo "Path error - skipping $i" ; continue ; }
|
cd "$(dirname "${ComposeFile}")" || { echo "Path error - skipping $i" ; continue ; }
|
||||||
docker pull "$ContImage"
|
docker pull "$ContImage"
|
||||||
|
### Reformat for multi-compose:
|
||||||
|
IFS=',' read -r -a Confs <<< "$ContConfigFile" ; unset IFS
|
||||||
|
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:
|
||||||
if [ -n "$ContEnv" ]; then
|
if [ -n "$ContEnv" ]; then
|
||||||
$DockerBin -f "$ComposeFile" --env-file "$ContEnv" up -d "$ContName"
|
$DockerBin ${CompleteConfs[@]} --env-file "$ContEnv" up -d "$ContName" # unquoted array to allow split - rework?
|
||||||
else
|
else
|
||||||
$DockerBin -f "$ComposeFile" up -d "$ContName"
|
$DockerBin ${CompleteConfs[@]} up -d "$ContName" # unquoted array to allow split - rework?
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
printf "\033[0;32mAll done!\033[0m\n"
|
printf "\033[0;32mAll done!\033[0m\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user