Created
July 26, 2017 04:14
-
-
Save rajiteh/7b9f655cc400ba49d6b2bca78bd1469b to your computer and use it in GitHub Desktop.
Ghetto Docker Update
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
RUNNING="$(docker ps --format "{{ .ID }}" | xargs docker inspect --format "{{ .Image }}" | xargs docker inspect --format "{{ .Id }} {{ .RepoTags }}")" | |
AVAILABLE="$(docker images --format "{{ .ID }} [{{ .Repository }}:{{ .Tag }}]" --no-trunc)" | |
NEEDS_UPDATE=0 | |
echo "${RUNNING}" | while read line; do | |
current_id=$(echo "${line}" | awk '{print $1}') | |
current_tag=$(echo "${line}" | awk '{print $2}') | |
updated_id=$(echo "${AVAILABLE}" | grep -F "${current_tag}" | awk '{print $1}') | |
if [ "$current_id" != "$updated_id" ]; then | |
echo "Update required for ${current_tag}" | |
NEEDS_UPDATE=1 | |
fi | |
done | |
exit ${NEEDS_UPDATE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment