Guest User

Untitled

a guest
Mar 22nd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Pull down the latest docker images
  4. #
  5. # "docker-compose pull" will pull down the latest images but will not do it
  6. # intelligently as it will attempt to update things multiple times if they
  7. # are dependencies of several services (eg. mysql).
  8. #
  9. # It will also only work on the current directory.
  10. #
  11. # This script will:
  12. # - Only attempt to update an image *once*.
  13. # - Process all the docker-compose.yml files in the given directory and
  14. # all subdirectories.
  15.  
  16. if [ "$#" -ne 1 ] || ! [ -d "$1" ]; then
  17. echo "Usage: $0 [directory]" >&2
  18. exit 1
  19. fi
  20.  
  21. cd $1
  22.  
  23. # Find all non-vendor docker-compose.yml files.
  24. files=$(find . -name docker-compose.yml | egrep -v 'vendor|node_modules')
  25.  
  26. # Pull out the images used
  27. # Have to filter out "image: {ecr}/{repo}:{tag}"
  28. images=$(grep -h image: $files | grep -v '{' | awk '{ print $2 }' | sort | uniq)
  29.  
  30. # Now do the update
  31. for image in $images
  32. do
  33. docker pull $image
  34. done
Add Comment
Please, Sign In to add comment