I came here trying to find a similar problem ... found part of the solution in a comment by Nikolai Gurov, which I modified to understand:
docker ps -aq | grep -v -E $(docker ps -aq --filter='name=mvn_repo' | paste -sd "|" -)
Mykola's solution only works if there is one match for the docker ps filter. Therefore, if you have a whole bunch of containers, you want to exclude this match from the filter pattern - it will fail, because grep can only work with one expression.
The solution I provided converts the output of this to a regular expression and then uses grep with an extended regular expression.
To break it ...
docker ps -aq --filter='name=mvn_repo' | paste -sd "|" -
produces a conclusion as follows:
d5b377495a58|2af19e0029a4
where is the result of each container identifier associated with the symbol | , to formulate a regular expression that can then be used with grep.
Then, when it is used in a subdomain using grep:
grep -v -E $(docker ps -aq --filter='name=mvn_repo' | paste -sd "|" -)
resolves something like this:
grep -v -E d5b377495a58|2af19e0029a4
then when we can then output the output of docker ps -aq to get something like this:
docker ps -aq | grep -v -E d5b377495a58|2af19e0029a4
source share