How to update all docker base images with one command

 
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!
Andrea

Leave a Reply

Your email address will not be published.