I'm using docker-compose up --scale
to create multiple versions of the same container. As a result I end up with containers named container_foo_1
, container_foo_2
etc.
Does docker support any kind of glob / wildcard matching on container names in it's command line tools? What I want to do is this:
docker inspect container_foo_*
What I'm doing right now in the short term is just using:
docker-inspect container_foo_{1,2}
(using bash brace expansion)
but I'd love if there was a way where I didn't know how many containers there were / what the numbers were ahead of time.
You can use the argument --filter | -f
at docker ps
with docker inspect
.
Usage: docker ps --filter key=value
,
where value
accept regular expressions.
The currently supported filters are:
id
Container’s IDname
Container’s namelabel
An arbitrary string representing either a key or a key-value pair. Expressed as or =exited
An integer representing the container’s exit code. Only useful with --all.status
One of created, restarting, running, removing, paused, exited, or deadancestor
Filters containers which share a given image as an ancestor. Expressed as * [:], , or image@digestbefore or since
Filters containers created before or after a given container ID or namevolume
Filters running containers which have mounted a given volume or bind mount.network
Filters running containers connected to a given network.publish or expose
Filters containers which publish or expose a given port. Expressed as <port>[/<proto>]
or <startport-endport>/[<proto>]
health
Filters containers based on their healthcheck status. One of starting, healthy, unhealthy or none.isolation
Windows daemon only. One of default, process, or hyperv.is-task
Filters containers that are a “task” for a service. Boolean option (true or false)Ex: docker inspect $(docker ps --filter name=^/server --quiet)
References:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With