Search code examples
dockerdocker-cli

docker ps command's filter with NOT condition


I am using minkube as docker engine. So I can get the many container instances related minikube containers with 'docker ps' command. I want to see the containers without them.

minikube containers's name start with 'k8s-bra-bra' so I want to filter using that.

docker ps command support --filter options but I don't know how to set NOT condition like docker ps --filter "name!=k8s*". please help. thanks.


Solution

  • I took a look at the Docker documentation and there doesn't seem to be a default way of setting a NOT condition like that.
    However, you can use the grep command to do the filtering:

    docker ps | grep -v "k8s"
    

    The -v option tells grep to exclude all the matching patterns.