<p>In short:
I want to remove a docker image, but if I do so it tells me that it cannot be removed because the image is being used by a running container. But as far as I can tell there is no container running at all.</p>
<p>In detail:
I call <code>docker images -a</code> to see call images. This way I determine the Image ID which I want to delete and call <code>docker image rm {ID}</code> where {ID} is the String which should be deleted (it worked for other images so I am pretty confident so far).
I get the response:</p>
<p><em>Error response from daemon: conflict: unable to delete {ID} (cannot be forced) - image is being used by running container 08815cd48523</em>
(The ID at the end seems to change with every call)</p>
<p>This error appears to be pretty easy to understand, but if I call <code>docker ps -a</code>, it shows me that I do not have a single container running and therefore no container running with the specified ID.</p>
<p>This problem occurs with some images. But all seem to be related to Kubernetes.
Does anyone know what the problem is?</p>
<p>As asked for in the comments hear docker inspect on one of the invisible containers (I replaced all part where I was not sure if it contains sensetive data with &quot;removed_for_post&quot;):</p>
<pre><code>[
    {
        &quot;Id&quot;: &quot;Removed_for_post&quot;,
        &quot;Created&quot;: &quot;2021-10-05T07:04:33.2059908Z&quot;,
        &quot;Path&quot;: &quot;/pause&quot;,
        &quot;Args&quot;: [],
        &quot;State&quot;: {
            &quot;Status&quot;: &quot;running&quot;,
            &quot;Running&quot;: true,
            &quot;Paused&quot;: false,
            &quot;Restarting&quot;: false,
            &quot;OOMKilled&quot;: false,
            &quot;Dead&quot;: false,
            &quot;Pid&quot;: 3570,
            &quot;ExitCode&quot;: 0,
            &quot;Error&quot;: &quot;&quot;,
            &quot;StartedAt&quot;: &quot;2021-10-05T07:04:33.4266642Z&quot;,
            &quot;FinishedAt&quot;: &quot;0001-01-01T00:00:00Z&quot;
        },
        &quot;Image&quot;: &quot;sha256:80d28bedfe5dec59da9ebf8e6260224ac9008ab5c11dbbe16ee3ba3e4439ac2c&quot;,
        &quot;ResolvConfPath&quot;: &quot;/var/lib/docker/containers/ Removed_for_post /resolv.conf&quot;,
        &quot;HostnamePath&quot;: &quot;/var/lib/docker/containers/ Removed_for_post /hostname&quot;,
        &quot;HostsPath&quot;: &quot;/var/lib/docker/containers/ Removed_for_post /hosts&quot;,
        &quot;LogPath&quot;: &quot;/var/lib/docker/containers/ Removed_for_post / Removed_for_post -json.log&quot;,
        &quot;Name&quot;: &quot;/k8s_POD_etcd-docker-desktop_kube-system_ Removed_for_post &quot;,
        &quot;RestartCount&quot;: 0,
        &quot;Driver&quot;: &quot;overlay2&quot;,
        &quot;Platform&quot;: &quot;linux&quot;,
        &quot;MountLabel&quot;: &quot;&quot;,
        &quot;ProcessLabel&quot;: &quot;&quot;,
        &quot;AppArmorProfile&quot;: &quot;&quot;,
        &quot;ExecIDs&quot;: null,
        &quot;HostConfig&quot;: {
            &quot;Binds&quot;: null,
            &quot;ContainerIDFile&quot;: &quot;&quot;,
            &quot;LogConfig&quot;: {
                &quot;Type&quot;: &quot;json-file&quot;,
                &quot;Config&quot;: {}
            },
            &quot;NetworkMode&quot;: &quot;host&quot;,
            &quot;PortBindings&quot;: {},
            &quot;RestartPolicy&quot;: {
                &quot;Name&quot;: &quot;&quot;,
                &quot;MaximumRetryCount&quot;: 0
            },
            &quot;AutoRemove&quot;: false,
            &quot;VolumeDriver&quot;: &quot;&quot;,
            &quot;VolumesFrom&quot;: null,
            &quot;CapAdd&quot;: null,
            &quot;CapDrop&quot;: null,
            &quot;CgroupnsMode&quot;: &quot;host&quot;,
            &quot;Dns&quot;: null,
            &quot;DnsOptions&quot;: null,
            &quot;DnsSearch&quot;: null,
            &quot;ExtraHosts&quot;: null,
            &quot;GroupAdd&quot;: null,
            &quot;IpcMode&quot;: &quot;shareable&quot;,
            &quot;Cgroup&quot;: &quot;&quot;,
            &quot;Links&quot;: null,
            &quot;OomScoreAdj&quot;: -998,
            &quot;PidMode&quot;: &quot;&quot;,
            &quot;Privileged&quot;: false,
            &quot;PublishAllPorts&quot;: false,
            &quot;ReadonlyRootfs&quot;: false,
            &quot;SecurityOpt&quot;: [
                &quot;no-new-privileges&quot;
            ],
            &quot;UTSMode&quot;: &quot;&quot;,
            &quot;UsernsMode&quot;: &quot;&quot;,
            &quot;ShmSize&quot;: 67108864,
            &quot;Runtime&quot;: &quot;runc&quot;,
            &quot;ConsoleSize&quot;: [
                0,
                0
            ],
            &quot;Isolation&quot;: &quot;&quot;,
            &quot;CpuShares&quot;: 2,
            &quot;Memory&quot;: 0,
            &quot;NanoCpus&quot;: 0,
            &quot;CgroupParent&quot;: &quot;/kubepods/kubepods/besteffort/removed_for_Post&quot;,
            &quot;BlkioWeight&quot;: 0,
            &quot;BlkioWeightDevice&quot;: null,
            &quot;BlkioDeviceReadBps&quot;: null,
            &quot;BlkioDeviceWriteBps&quot;: null,
            &quot;BlkioDeviceReadIOps&quot;: null,
            &quot;BlkioDeviceWriteIOps&quot;: null,
            &quot;CpuPeriod&quot;: 0,
            &quot;CpuQuota&quot;: 0,
            &quot;CpuRealtimePeriod&quot;: 0,
            &quot;CpuRealtimeRuntime&quot;: 0,
            &quot;CpusetCpus&quot;: &quot;&quot;,
            &quot;CpusetMems&quot;: &quot;&quot;,
            &quot;Devices&quot;: null,
            &quot;DeviceCgroupRules&quot;: null,
            &quot;DeviceRequests&quot;: null,
            &quot;KernelMemory&quot;: 0,
            &quot;KernelMemoryTCP&quot;: 0,
            &quot;MemoryReservation&quot;: 0,
            &quot;MemorySwap&quot;: 0,
            &quot;MemorySwappiness&quot;: null,
            &quot;OomKillDisable&quot;: false,
            &quot;PidsLimit&quot;: null,
            &quot;Ulimits&quot;: null,
            &quot;CpuCount&quot;: 0,
            &quot;CpuPercent&quot;: 0,
            &quot;IOMaximumIOps&quot;: 0,
            &quot;IOMaximumBandwidth&quot;: 0,
            &quot;MaskedPaths&quot;: [
                &quot;/proc/asound&quot;,
                &quot;/proc/acpi&quot;,
                &quot;/proc/kcore&quot;,
                &quot;/proc/keys&quot;,
                &quot;/proc/latency_stats&quot;,
                &quot;/proc/timer_list&quot;,
                &quot;/proc/timer_stats&quot;,
                &quot;/proc/sched_debug&quot;,
                &quot;/proc/scsi&quot;,
                &quot;/sys/firmware&quot;
            ],
            &quot;ReadonlyPaths&quot;: [
                &quot;/proc/bus&quot;,
                &quot;/proc/fs&quot;,
                &quot;/proc/irq&quot;,
                &quot;/proc/sys&quot;,
                &quot;/proc/sysrq-trigger&quot;
            ]
        },
        &quot;GraphDriver&quot;: {
            &quot;Data&quot;: {
                &quot;LowerDir&quot;: &quot;/var/lib/docker/overlay2/ Removed_for_post -init/diff:/var/lib/docker/overlay2/ Removed_for_post /diff&quot;,
                &quot;MergedDir&quot;: &quot;/var/lib/docker/overlay2/Removed_for_post /merged&quot;,
                &quot;UpperDir&quot;: &quot;/var/lib/docker/overlay2/Removed_for_post /diff&quot;,
                &quot;WorkDir&quot;: &quot;/var/lib/docker/overlay2/Removed_for_post /work&quot;
            },
            &quot;Name&quot;: &quot;overlay2&quot;
        },
        &quot;Mounts&quot;: [],
        &quot;Config&quot;: {
            &quot;Hostname&quot;: &quot;docker-desktop&quot;,
            &quot;Domainname&quot;: &quot;&quot;,
            &quot;User&quot;: &quot;&quot;,
            &quot;AttachStdin&quot;: false,
            &quot;AttachStdout&quot;: false,
            &quot;AttachStderr&quot;: false,
            &quot;Tty&quot;: false,
            &quot;OpenStdin&quot;: false,
            &quot;StdinOnce&quot;: false,
            &quot;Env&quot;: [
                &quot;PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot;
            ],
            &quot;Cmd&quot;: null,
            &quot;Image&quot;: &quot;k8s.gcr.io/pause:3.2&quot;,
            &quot;Volumes&quot;: null,
            &quot;WorkingDir&quot;: &quot;/&quot;,
            &quot;Entrypoint&quot;: [
                &quot;/pause&quot;
            ],
            &quot;OnBuild&quot;: null,
            &quot;Labels&quot;: {
                &quot;annotation.kubeadm.kubernetes.io/etcd.advertise-client-urls&quot;: &quot;https://192.168.65.4:2379&quot;,
                &quot;annotation.kubernetes.io/config.hash&quot;: &quot; Removed_for_post &quot;,
                &quot;annotation.kubernetes.io/config.seen&quot;: &quot;2021-10-05T07:04:32.243805800Z&quot;,
                &quot;annotation.kubernetes.io/config.source&quot;: &quot;file&quot;,
                &quot;component&quot;: &quot;etcd&quot;,
                &quot;io.kubernetes.container.name&quot;: &quot;POD&quot;,
                &quot;io.kubernetes.docker.type&quot;: &quot;podsandbox&quot;,
                &quot;io.kubernetes.pod.name&quot;: &quot;etcd-docker-desktop&quot;,
                &quot;io.kubernetes.pod.namespace&quot;: &quot;kube-system&quot;,
                &quot;io.kubernetes.pod.uid&quot;: &quot;removed for Post&quot;,
                &quot;tier&quot;: &quot;control-plane&quot;
            }
        },
        &quot;NetworkSettings&quot;: {
            &quot;Bridge&quot;: &quot;&quot;,
            &quot;SandboxID&quot;: &quot; Removed_for_post&quot;,
            &quot;HairpinMode&quot;: false,
            &quot;LinkLocalIPv6Address&quot;: &quot;&quot;,
            &quot;LinkLocalIPv6PrefixLen&quot;: 0,
            &quot;Ports&quot;: {},
            &quot;SandboxKey&quot;: &quot;/var/run/docker/netns/default&quot;,
            &quot;SecondaryIPAddresses&quot;: null,
            &quot;SecondaryIPv6Addresses&quot;: null,
            &quot;EndpointID&quot;: &quot;&quot;,
            &quot;Gateway&quot;: &quot;&quot;,
            &quot;GlobalIPv6Address&quot;: &quot;&quot;,
            &quot;GlobalIPv6PrefixLen&quot;: 0,
            &quot;IPAddress&quot;: &quot;&quot;,
            &quot;IPPrefixLen&quot;: 0,
            &quot;IPv6Gateway&quot;: &quot;&quot;,
            &quot;MacAddress&quot;: &quot;&quot;,
            &quot;Networks&quot;: {
                &quot;host&quot;: {
                    &quot;IPAMConfig&quot;: null,
                    &quot;Links&quot;: null,
                    &quot;Aliases&quot;: null,
                    &quot;NetworkID&quot;: &quot; Removed_for_post &quot;,
                    &quot;EndpointID&quot;: &quot; Removed_for_post &quot;,
                    &quot;Gateway&quot;: &quot;&quot;,
                    &quot;IPAddress&quot;: &quot;&quot;,
                    &quot;IPPrefixLen&quot;: 0,
                    &quot;IPv6Gateway&quot;: &quot;&quot;,
                    &quot;GlobalIPv6Address&quot;: &quot;&quot;,
                    &quot;GlobalIPv6PrefixLen&quot;: 0,
                    &quot;MacAddress&quot;: &quot;&quot;,
                    &quot;DriverOpts&quot;: null
                }
            }
        }
    }
]``
</code></pre>

Manuel 
<p>Your container seems to be created by an other tool like docker-compose as I guess it is local on your computer..</p>
<p>Which means you can not stop its creation with docker rm statement easily.</p>
<h2>EDIT 1 - Kubernetes</h2>
<ul>
<li>You seems to be using docker desktop</li>
<li>Your container seems to be <code>etcd</code> which is part of kubernetes master system (very important) :</li>
</ul>
<blockquote>
<p>k8s_POD_etcd-docker-desktop_kube-system_ Removed_for_post</p>
</blockquote>
<p>So, as it is part of kubernetes components, you should remove it only if you want to not use kubernetes.</p>
<blockquote>
<p>By removing kubernetes or etcd pod.</p>
</blockquote>
<p>If docker-desktop, should not be a problem.</p>
<p>To summarize, <code>your container is created by a pod which is a resource handled by kubernetes</code></p>
<h2>docker-compose</h2>
<ul>
<li>find your docker-compose directory, usually containers names start with project name and go int its directory.</li>
<li>execute <code>docker-compose down</code></li>
</ul>
<h2>docker</h2>
<ul>
<li>Try to restart docker daemon,
for instance in a linux based environment :
<code>sudo systemctl restart docker</code></li>
<li>A reboot of your machine should works too.</li>
</ul>
<p>Finally you should be able to remove containers as proposed in your question.</p>
