Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update (pull) all docker images at once

Tags:

linux

docker

Is there a command to update (pull) all the downloaded Docker images at once in the terminal ?

like image 597
Pierre HUBERT Avatar asked Jul 06 '17 15:07

Pierre HUBERT


People also ask

How do I automatically update docker images?

By pushing a new Docker image to your repository, Watchtower will automatically trigger a chain of events to update your running container's base Docker image. When Watchtower detects a new push, it will pull the new base image, gracefully shutdown your running container, and start it back up.

Can you pull multiple docker images?

Pull a repository with multiple images By default, docker pull pulls a single image from the registry. A repository can contain multiple images. To pull all images from a repository, provide the -a (or --all-tags ) option when using docker pull .

Can docker images be updated?

To update to a newer image, you first need to pull the new version. Run the docker pull command followed by a colon and the name and the tag of the newer image: the name and tag that you took note of previously.


2 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;
like image 128
François Maturel Avatar answered Sep 19 '22 11:09

François Maturel


You can use this :

docker images | awk '{print $1":"$2}' | grep -v REPOSITORY | xargs -L1 docker pull 
like image 41
Sidahmed Avatar answered Sep 19 '22 11:09

Sidahmed