Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make docker container ls -f name filter by exact name?

Tags:

docker

docker container ls -f name=foo returns all containers which have names that contain foo. This means it also return a container named foobar, for example. How can I filter for all the containers named exactly foo?

like image 523
Anna Ira Hurnaus Avatar asked Feb 13 '18 13:02

Anna Ira Hurnaus


1 Answers

docker container ls -f name=^/foo$

It can be achieved by using a regular expression. The caret ^ matches the exact start of the name and the dollar $ matches the end.

The slash / is needed because the filter mechanism expects the name prefixed with a slash.

like image 127
Anna Ira Hurnaus Avatar answered Sep 21 '22 11:09

Anna Ira Hurnaus