Error response from daemon: conflict: unable to delete (must be forced) code example

Example: Docker error Error response from daemon: conflict: unable to remove repository reference

docker container rm <container id>
docker image rm <test-image>

NOTE:
prashad@ubuntu:$ docker rmi test-image:latest 
Error response from daemon: conflict: unable to remove repository reference "test-mage:latest" (must force) - container d5bc2a9f3cdd is using its referenced image e7dae29d77e4

i.e., test-image associated container id is still present, so we can't remove test-image.
First remove container and followed by test-image.

#Delete respective container
prashad@ubuntu:$ docker container rm d5bc2a9f3cdd
d5bc2a9f3cdd
#Delete test-image
prashad@ubuntu:$ docker rmi test-image:latest
Untagged: test-image:latest
Deleted: sha256:e7dae29d77e455b5351b9b85255bc4351a6ee0b76db21f9bdde03c844bbd5595
Deleted: sha256:c4bdc799981a7da280107416c7e568fec9609ac79975f5f1e02fa26140540f12
Deleted: sha256:69e34e04908ae30c81178d6b79f978a59810d02185c404a1f452bb723ccb0760
Deleted: sha256:c6ad6b545852e386210bb56be297a275bcb684afa208bb45d384432c5f56698b
Deleted: sha256:b17687cdf54b2fb7ca0b63d7679dab415a949b66f60f90e07274041eb39a02e4

Tags:

C Example