Quick solution:
docker --host unix:///$HOME/Library/Containers/com.docker.docker/Data/docker.raw.sock ps -a
Explanation:
It seems to be an expected behavior from Docker developers point of view.
Mac version of Docker is using specific socket to connect docker-cli
to the daemon that runs on Hyperkit VM.
It works in exactly the same way if you are using docker binary shipped with Docker.app or installed separately.
Luckily Docker-desktop for MacOS creates two kind of sockets:
A "filtered" socket ( used by default ) for the purpose of Docker-desktop application requirements, probably related to its Kubernetes implementation:
$HOME/Library/Containers/com.docker.docker/Data/docker.sock
and the unfiltered one:
$HOME/Library/Containers/com.docker.docker/Data/docker.raw.sock
To show the differences, I've reproduced your situation and got the container with ID: b2f1fed9c793
in Exited
state:
$ docker inspect b2f1fed9c793 | grep Status
"Status": "exited",
$ docker ps -a | grep b2f1fed9c793
# empty output
When I run the same command connecting to the different sockets I'm getting different results and only raw socket shows exited containers:
$ docker --host unix:///$HOME/Library/Containers/com.docker.docker/Data/docker.sock ps -a | grep b2f1fed9c793
# empty output
$ docker --host unix:///$HOME/Library/Containers/com.docker.docker/Data/docker.raw.sock ps -a | grep b2f1fed9c793
b2f1fed9c793 nginx "nginx -g 'daemon of…" 40 minutes ago Exited (0) 39 minutes ago k8s_nginx_nginx3_default_2a5ed89d-ccff-4561-a320-676603d30619_4
Default socket gives 0 lines with Exited containers:
$ docker --host unix:///$HOME/Library/Containers/com.docker.docker/Data/docker.sock ps -a | grep Exited | wc -l
0
But raw socket gives 22:
$ docker --host unix:///$HOME/Library/Containers/com.docker.docker/Data/docker.raw.sock ps -a | grep Exited | wc -l
22
To use the raw socked by default you can create an alias:
$ alias docker="docker --host unix:///$HOME/Library/Containers/com.docker.docker/Data/docker.raw.sock"
$ docker ps -a | grep Exited | wc -l
22
The solution was originally suggested by lalyos in the issue comment, but he was solving slightly different problem.