The image could be currently used by a running container, so you first have to stop and remove the container(s).
docker stop <container-name>
docker rm <container-id>
Then you could try deleting the image:
docker rmi <image-id>
You must be sure that this image doesn't depend on other images (otherwise you must delete them first).
I had a strange case in which I had no more containers still alive (docker ps -a
returned nothing) but I couldn't manage to delete the image and its image-dependency.
To solve these special cases you could force the image removal with this:
docker rmi -f <image-id>