Is there a command to update (pull) all the downloaded Docker images at once in the terminal ?
3 Answers
No, there is no built-in command to pull
all docker images
at once.
But you can try this (multiline) bash using docker --format
:
for image in $(docker images --format "{{.Repository}}:{{.Tag}}" | grep -v '<none>')
do
docker pull $image
done
Or in one line:
for image in $(docker images --format "{{.Repository}}:{{.Tag}}" | grep -v '<none>'); do docker pull $image; done;
You can use this :
docker images | awk '{print $1":"$2}' | grep -v REPOSITORY | xargs -L1 docker pull
The most "dockerist" way to do it is:
docker images --format "{{.Repository}}:{{.Tag}}" | xargs -L1 docker pull
-
While docker image names and tags may not contain blanks, which
xargs
would then use to split it into multiple arguments, it might still be a good idea to explicit set the line separator\n
as the only valid character used for splitting:-d '\n'
And while we are at it, also a-r
or--no-run-if-empty
to not run any command when currently no local image exists. And<none>
should be filtered out.– pmhahnJan 27 at 7:54 -
Thanks for your comments @pmhahn Think that
xargs -d
is not available in all *nix systems like FreeBSD. I will keep the answer without your suggestions to have a closer answer to most scenarios. Jan 28 at 10:10