After doing pull, I am trying to check if the container is running with the last image available
with something like this
for container in $(docker-compose ps -q)
do
oldImage=$(docker inspect $container -f "{{.Image}}" | sed 's/sha256://')
imageName=$(docker inspect $container -f "{{.Config.Image}}")
newImage=$(docker image inspect $imageName -f "{{.Id}}" | sed 's/sha256://')
if [[ "$newImage" != "$oldImage" ]]; then
echo "new image found $imageName"
echo "new image $newImage"
echo "old image $oldImage"
echo "restaring ... "
fi
done
I could check if the container's image is different from the new image available, but I don't have the service name to restart it.
Some ideas?