In docker I can make docker inspect -f "{{ .NetworkSettings.IPAddress }}" CONTAINER
to run command on a particular container.
What I need is to do something like
docker inspect -f "{{ .NetworkSettings.IPAddress }}" all
or
docker inspect -f "{{ .NetworkSettings.IPAddress }}" *
to run a command on all containers, not mentioning their names explicitly?
It relates to other docker commands as well. Is there such a way without bash scripting?
You can list multiple container to a docker inspect
.
docker inspect [OPTIONS] CONTAINER|IMAGE [CONTAINER|IMAGE...]
But the only way to list those container is through bash $(sudo docker ps -aq)
.
For example:
docker inspect --format='{{.Name}}' $(sudo docker ps -aq)
docker inspect -f "{{ .NetworkSettings.IPAddress }}" $(sudo docker ps -aq)
The OP f1yegor proposes in the comments:
all=$(sudo docker ps -aq) docker inspect -f "{{ .NetworkSettings.IPAddress }}" $all