Problem
You tried to delete an image but received the following error message[root@centos7 docker]# docker rmi d0b4a01f1562
Error response from daemon: conflict: unable to delete d0b4a01f1562 (must be forced) - image is being used by stopped container 98f6a5df3226
Solution
Run the following command to list container with exited state[root@centos7 docker]# docker ps --filter "status=exited"
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
979e2873a16e 96f5373b33b7 "/bin/sh -c '$JBOSS_H" 2 hours ago Exited (127) 2 hours ago evil_fermi
e1c5ce9a8b9c ef5a0201b5c2 "/bin/sh -c 'yum -y u" 2 hours ago Exited (126) 2 hours ago boring_swanson
98f6a5df3226 d0b4a01f1562 "/bin/sh -c 'unzip /t" 2 hours ago Exited (127) 2 hours ago desperate_knuth
62db7be0cc59 7a69c0ca54ef "/bin/sh -c 'subscrip" 2 hours ago Exited (1) 2 hours ago naughty_carson
be10ff34189d 7a69c0ca54ef "/bin/sh -c 'subscrip" 2 hours ago Exited (1) 2 hours ago cocky_pare
65fd609bd328 7a69c0ca54ef "/bin/sh -c 'subscrip" 3 hours ago Exited (1) 3 hours ago suspicious_aryabhata
4793dd8fc355 e1e33a64e1f2 "/bin/sh -c 'apt-get " 20 hours ago Exited (127) 20 hours ago compassionate_hawking
4c810163a0eb registry.access.redhat.com/rhel7.3 "/bin/bash" 22 hours ago Exited (1) 21 hours ago loving_mayer
cd6bf1b1b154 395d9b3d55fe "/bin/sh -c 'subscrip" 22 hours ago Exited (1) 22 hours ago tender_gates
7badf972bc09 395d9b3d55fe "/bin/sh -c 'subscrip" 22 hours ago Exited (1) 22 hours ago amazing_liskov
790495e566fb 395d9b3d55fe "/bin/sh -c 'subscrip" 22 hours ago Exited (1) 22 hours ago furious_hopper
f7c1b9defc7c registry.access.redhat.com/rhel7.3 "/bin/bash"
92de70df12f0 395d9b3d55fe "/bin/sh -c 'apt-get " 22 hours ago Exited (127) 22 hours ago zen_jepsen
fe6e743a0ed0 395d9b3d55fe "/bin/sh -c 'yum upda" 23 hours ago Exited (1) 23 hours ago gigantic_agnesi
c00625480570 98776dd34e6d "/bin/sh -c 'yum upda" 23 hours ago Exited (1) 23 hours ago gloomy_shannon
02f74106ed39 registry.access.redhat.com/rhel7.3 "/bin/bash" 23 hours ago Exited (127) 23 hours ago stupefied_gates
d658f7182fcc e8e3aaf82af5 "/bin/bash" 23 hours ago Exited (0) 23 hours ago adoring_feynman
You can delete list of exited container with following commands
docker ps --filter "status=exited" | grep '2 hours ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm
Take note take that condition will also delete container with x2hours ago status.