Dockerexit code > 0

conflict: unable to delete image

$Error response from daemon: conflict: unable to delete 4c108a8 (must be forced) - image is being used by stopped container 8b12345

Analysis

You cannot delete an image because it is still being used (even if just referenced) by a container.

Common Triggers

  • Trying to remove an image when a container (running or stopped) is based on it.

Debug Checks

  • $Run docker ps -a to find the container mentioned in the error.

Resolution

1
Remove the container first: docker rm <container_id>.
2
Force remove the image: docker rmi -f <image_id>.