<p>I tried to remove a image using <code>docker rmi image_id</code> and terminal output <code>Error response from daemon: conflict: unable to delete dd85c346890b (must be forced) - image is being used by stopped container b91e905c2b8e</code>. Then I tried to list out the container using <code>docker ps -a</code> but it does not shown. Then I tried <code>docker inspect b91e905c2b8e</code> it does exists. And I can remove the container using <code>docker rm b91e905c2b8e</code>.<br></p>
<p>Why the container is not shown using <code>docker ps -a</code>. The container is created using <code>kubectl apply pod_config.yaml</code>. Will this affect docker?</p>
<p>Edited:<br>
pod.yaml</p>
<pre><code>apiVersion: v1 
kind: Pod 
metadata: 
  name: my-pod
  labels: 
    component: web
spec: 
  containers: 
    - name: client 
      image: imageB // original is imageA    
      ports: 
        - containerPort: 3000
</code></pre>

<p><strong>Quick solution:</strong></p>
<pre><code>docker --host unix:///$HOME/Library/Containers/com.docker.docker/Data/docker.raw.sock ps -a
</code></pre>
<p><strong>Explanation:</strong></p>
<p>It seems to be an expected behavior from Docker developers point of view.<br />
Mac version of Docker is using specific socket to connect <code>docker-cli</code> to the daemon that runs on Hyperkit VM.</p>
<p>It works in exactly the same way if you are using docker binary shipped with Docker.app or installed separately.</p>
<p>Luckily Docker-desktop for MacOS creates two kind of sockets:</p>
<p>A &quot;filtered&quot; socket ( used by default ) for the purpose of Docker-desktop application requirements, probably related to its Kubernetes implementation:</p>
<pre><code>$HOME/Library/Containers/com.docker.docker/Data/docker.sock
</code></pre>
<p>and the unfiltered one:</p>
<pre><code>$HOME/Library/Containers/com.docker.docker/Data/docker.raw.sock
</code></pre>
<p>To show the differences, I've reproduced your situation and got the container with ID: <code>b2f1fed9c793</code> in <code>Exited</code> state:</p>
<pre><code>$ docker inspect b2f1fed9c793 | grep Status
            &quot;Status&quot;: &quot;exited&quot;,

$ docker  ps -a | grep b2f1fed9c793
# empty output
</code></pre>
<p>When I run the same command connecting to the different sockets I'm getting different results and only raw socket shows exited containers:</p>
<pre><code>$ 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                              &quot;nginx -g 'daemon of…&quot;   40 minutes ago      Exited (0) 39 minutes ago                            k8s_nginx_nginx3_default_2a5ed89d-ccff-4561-a320-676603d30619_4
</code></pre>
<p>Default socket gives 0 lines with Exited containers:</p>
<pre><code>$ docker --host unix:///$HOME/Library/Containers/com.docker.docker/Data/docker.sock ps -a | grep Exited | wc -l 
       0
</code></pre>
<p>But raw socket gives 22:</p>
<pre><code>$ docker --host unix:///$HOME/Library/Containers/com.docker.docker/Data/docker.raw.sock ps -a | grep Exited | wc -l 
      22
</code></pre>
<p>To use the raw socked by default you can create an alias:</p>
<pre><code>$ alias docker=&quot;docker --host unix:///$HOME/Library/Containers/com.docker.docker/Data/docker.raw.sock&quot;

$ docker  ps -a | grep Exited | wc -l 
      22
</code></pre>
<p>The solution was originally suggested by <a href="https://github.com/lalyos" rel="nofollow noreferrer">lalyos</a> in the <a href="https://github.com/docker/cli/issues/2446#issuecomment-614880833" rel="nofollow noreferrer">issue comment</a>, but he was solving slightly different problem.</p>
