How to update all docker base images with one command

This post is over 3 years old, so please keep in mind that some of its content might not be relevant anymore.
for docker in $(docker images|awk '{print $1,$2}'|sed 's/ /:/g'|grep -v REPOSITORY); do docker pull $docker; done

This command updates all your docker images but don’t remove the old versions which have now been updated.

To do that, and clear some unnecessarily used space, you can run the ones tagged with “<none>”:

for dockerImage in $(docker images|awk '$2 == "<none>" {print $3}'); do docker rmi $dockerImage; done

NB: One liners are potentially destructive. Don’t run anything unless you fully understand it.

Hope it helps!

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: