Home > Blockchain >  Update all local docker images through console command
Update all local docker images through console command

Time:12-04

I need to update all docker images through console command. Full list:

andrey@BushM1 ~ % docker images --format "{{.Repository}}" | sort --unique               
bitnami/kafka
bitnami/zookeeper
confluentinc/cp-kafka
confluentinc/cp-kafka-connect
confluentinc/cp-schema-registry
confluentinc/cp-zookeeper
denoland/deno
mariadb
mcr.microsoft.com/azure-sql-edge
mcr.microsoft.com/dotnet/aspnet
mcr.microsoft.com/dotnet/runtime
mcr.microsoft.com/dotnet/sdk
mongo
mongo-express
mysql
node
portainer/portainer-ce
postgres
provectuslabs/kafka-ui
python
rabbitmq
redis
traefik
vault
wordpress
andrey@BushM1 ~ % 

I need something like this:

andrey@BushM1 ~ % docker pull $(docker images --format "{{.Repository}}" | sort --unique)
"docker pull" requires exactly 1 argument.
See 'docker pull --help'.

Usage:  docker pull [OPTIONS] NAME[:TAG|@DIGEST]

Pull an image or a repository from a registry
andrey@BushM1 ~ % 

How to write right iteration?

CodePudding user response:

Sounds like a typical job for xargs:

docker images --format "{{.Repository}}" | sort -u | xargs -n1 docker pull

See man xargs for more options. You can also just do a loop:

.... | while IFS= read -r line; do docker pull "$line"; done
  • Related