Jan Carlo Viray React · Angular · Node · SQL · Cloud · Entrepreneurship

Portfolio ·  LinkedIn ·  Twitter ·  Stack Overflow ·  Github ·  Contact Me

How to update all Docker images

Currently, Docker does not have a command to do this so we will have to do some good old fashioned command piping.

To automatically update all images:

docker images | grep -v REPOSITORY | awk '{print $1}' | xargs -L1 docker pull

Docker does not overwrite old images for us. To cleanup old images:

docker images | grep "<none>" | awk '{print $3}' | xargs -L1 docker rmi

Note that you must wait for the update process to finish. Here’s a summary of what each command does…

  • docker images lists all images in the system
  • grep -v REPOSITORY removes the header “REPOSITORY TAG IMAGE ID…..”
  • awk '{print $1'} prints the first column which is the image name
  • xargs -L1 docker pull passes each line to the command docker pull
If you have any questions or comments, please post them below. If you liked this post, you can share it with your followers or follow me on Twitter!