DEV Community

Goffity Corleone
Goffity Corleone

Posted on • Updated on

Update all docker images already pulled.

When we want to update all images that pulled. This is a command to use update all images at once. (This command will pull the latest tag)

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

I found this command a long time ago and I cannot remember the reference. I am sorry for the owner.


Edit 2021-12-21

Today I found a problem on MacOS with this command and fixed to use

docker images | grep -v REPOSITORY | awk 'BEGIN{OFS=":"} {print $1,$2}' | xargs -L1 docker pull
Enter fullscreen mode Exit fullscreen mode

Oldest comments (4)

Collapse
 
nandoabreu profile image
Fernando Abreu

That command will update all images, but will pull maybe more than you need. For instance, I use python:3.6-alpine (40MB) and postgres:13-alpine (158MB). That command downloads a new python:latest (880MB) and a new postgres:latest (314MB).

The command to update your existing images is:

docker images | grep -v ^REPO | sed 's/ \+/:/g' | cut -d: -f1,2 | xargs -L1 docker pull
Enter fullscreen mode Exit fullscreen mode

(my postgres:13-alpine was updated now, to 160MB)

And to clean unused and untaged images after that, run:

docker image prune
Enter fullscreen mode Exit fullscreen mode
Collapse
 
goffity profile image
Goffity Corleone

Thanks, It's very helpful.

Collapse
 
imjoseangel profile image
Jose Angel Munoz

@goffity the following:

docker images | grep -v REPOSITORY | awk 'BEGIN{OFS=":"} {print $1,$2}'
Enter fullscreen mode Exit fullscreen mode

can be easily done with:

docker images --format "{{.Repository}}:{{.Tag}}"
Enter fullscreen mode Exit fullscreen mode

So the final command would be:

docker images --format "{{.Repository}}:{{.Tag}}" | xargs -L1 docker pull
Enter fullscreen mode Exit fullscreen mode
Collapse
 
goffity profile image
Goffity Corleone

awesome ()/