Cant delete Docker image - docker

I want to delete a image but i get
Failed to remove image (b9387432d394): Error response from daemon:
conflict: unable to delete b9387432d394 (cannot be forced) - image has
dependent child images
I have done this a few times but never run into a problem like this.
Ive run a image (doesnt really care what it was)
$ docker run -dt ubuntu:16.04
Ive logged in and created a empty file
$ docker exec -it <my_container_id>
Ive logged out and create a new image with the commit command
$ exit
$ docker commit -m "some change" <container_id> <new_image_name>
Ive removed all containers
$ docker rm $(docker ps -a -q)
Ive verified that all containers are gone and my image is in the list
$ docker ps
// received a empty list
$ docker images
// received a list with the base and my new image
Ive tried to remove the base image
$ docker rmi -f <image_id>
But i received the error Failed to remove image

You can remove the untagged images using
docker rmi $(docker images -aq -f dangling=true)

Related

Docker rmi - Is it okay to use --force?

I am rather new to Docker, I have recently started running ubuntu container, and stopped it gracefully a few days later (I do not see it using "docker ps"). When I tried to remove ubuntu image using
docker rmi ubuntu
I got the following error:
Error response from daemon: conflict: unable to remove repository reference "ubuntu" (must force) - container 65c315b169b8 is using its referenced image 747cb2d
60bbe
Can I use "--force" to force a removal of the image,
docker rmi ubuntu --force
Or is there a graceful/safer way to do it?
By default docker ps will only show running containers. You can show the stopped ones using docker ps --all.
You can then remove the container first with docker rm <CONTAINER_ID>
If you want to remove all of the containers, stopped or not, you can achieve this from a bash prompt with
$ docker rm $(docker ps --all -q)
The -q switch returns only the IDs
Since everyone else seemed unwilling to test yet willing to preach, I decided to test this out myself:
I downloaded a new image so I knew it wasn't in use
I ran a new container
I deleted the image using docker rmi --force <name>
Image was only untagged, not deleted
I failed to delete the image using docker rmi --force <ID> as docker rebuked with "image is being used by running container 922a12161de6"
So the results are:
The image gets untagged when you name it, but Docker (at least the version I'm using, 19.03.5 build 633a0ea) is smart enough to not actually delete the layers when they are in use.
As a result, the container continues to run fine as the layers are still there, they're simply untagged. You can docker rmi <ID> or docker images prune (without -a it will only delete "dangling" images, I. E. not including unused ones).
Thus the answer is "yes, but it won't delete containers if that's what you're hoping for", but now you know why.
I'm not satisfied with how most of the other answers tell you to find running containers, however, since they seem to say "list all images" -- why? You're trying to delete a specific image.
Stefano's answer is more accurate but here are some tweaks to it:
imageName=ubuntu
containerIds=$(docker ps -a | grep "$imageName" | awk '{ print $1 }')
docker stop $containerIds
docker rm $containerIds
docker rmi "$imageName"
Basically, I added a variable for the image naem and a stop step.
Docker doesn't copy the image data to each container, all the containers running the image have a read only pointer to that part of the filesystem (with their own local RW layer for the individual containers). So if you delete an image while a container is using it, you would break the container and overlay filesystem that it depends on.
Instead, just remove the container first. It may be exited rather than running, so you can do a docker ps -a | grep $image_id for a quick list of containers running that specific image id, but the preferred list would include any descendants:
docker rm $(docker ps -aq --filter "ancestor=747cb2d60bbe")
Then you'll be able to run your docker image rm (or docker rmi) command.
Update: If you force remove an image, all docker does is untag it. The image layers still exists on the filesystem until the container is deleted and then you can delete those image layers. E.g.:
/ $ docker run -d --rm busybox tail -f /dev/null
dac68c445371feab453ba3e3fc80efee52043f6b177fd0a71d0b55b38753f2cf
/ $ docker image rm busybox
Error response from daemon: conflict: unable to remove repository reference "busybox" (must force) - container dac68c445371 is using its referenced image 020584afccce
/ $ docker image rm --force busybox
Untagged: busybox:latest
Untagged: busybox#sha256:1303dbf110c57f3edf68d9f5a16c082ec06c4cf7604831669faf2c712260b5a0
/ $ docker image ls -a
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 020584afccce 2 weeks ago 1.22MB
Even after deleting the container the layers are still there:
/ $ docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dac68c445371 020584afccce "tail -f /dev/null" 52 seconds ago Up 50 seconds brave_yalow
/ $ docker stop dac
dac
/ $ docker image ls -a
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 020584afccce 2 weeks ago 1.22MB
But after the container has been removed you can cleanup the layers:
/ $ docker image prune
WARNING! This will remove all dangling images.
Are you sure you want to continue? [y/N] y
Deleted Images:
deleted: sha256:020584afccce44678ec82676db80f68d50ea5c766b6e9d9601f7b5fc86dfb96d
deleted: sha256:1da8e4c8d30765bea127dc2f11a17bc723b59480f4ab5292edb00eb8eb1d96b1
Total reclaimed space: 1.22MB
If you want to do it gracefully, you should find if there are other images using ubuntu. Anyway in your case, you have a container related to that image.
Here's an example script on how to get this:
containerId=$( docker container ls -a | grep ubuntu | awk '{ print $1 }' )
docker container rm $containerId
docker image rm ubuntu
Remove all containers and after all images to win some space !
$ docker rm $(docker ps -all -q)
$ docker rmi $(docker image ls -q)
You can try the prune option available with docker images in case you want to remove all unused images.
https://docs.docker.com/engine/reference/commandline/image_prune/#usage
docker image prune -a
When would one delete docker images
When they are short of disk space and
They know for certain that they dont need an image or if they can readily download from internet/docker registry later when they need
So if you have internet access and if you have disk space issues you can just delete the image by force
Why you are getting the error:
Docker thinks there is a container - which is currently stopped - which was using this image. If you delete this stopped docker, "docker rmi" would work without force
These are the basic useful commands for docker to view and delete stuff.
View all docker images: docker image ls
View docker containers: docker ps
Stop docker container: docker stop <container name>
Remove docker container: docker rm <container name>
Remove docker image: docker rmi image <image name>
Delete Docker images except for current one - docker image prune -a

Docker error cannot delete docker container, conflict: unable to remove repository reference

I want to remove the container at Docker, but an error occurs when you want to delete
My next step before removing the container, see the list of existing container
sts#Yudi:~/docker$ sudo docker ps -as
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES SIZE
78479ffeba5c ubuntu "/bin/bash" 42 hours ago Exited (0) 42 hours ago sharp_wescoff 81 B (virtual 187.7 MB)
0bd2b54678c7 training/webapp "python app.py" 5 days ago Exited (0) 5 days ago backstabbing_ritchie 0 B (virtual 323.7 MB)
0adbc74a3803 training/webapp "python app.py" 5 days ago Exited (143) 5 days ago drunk_feynman 0 B (virtual 323.7 MB)
one I want to delete the list, namely "training / webapp"
but an error that occurred
sts#Yudi:~/docker$ sudo docker rmi training/webapp
Error response from daemon: conflict: unable to remove repository reference "training/webapp" (must force) - container 0bd2b54678c7 is using its referenced image 54bb4e8718e8
Error: failed to remove images: [training/webapp]
Whether the container is running in the images?
Please help
There is a difference between docker images and docker containers. Check this SO Question.
In short, a container is a runnable instance of an image. which is why you cannot delete an image if there is a running container from that image. You just need to delete the container first.
docker ps -a # Lists containers (and tells you which images they are spun from)
docker images # Lists images
docker rm <container_id> # Removes a stopped container
docker rm -f <container_id> # Forces the removal of a running container (uses SIGKILL)
docker rmi <image_id> # Removes an image
# Will fail if there is a running instance of that image i.e. container
docker rmi -f <image_id> # Forces removal of image even if it is referenced in multiple repositories,
# i.e. same image id given multiple names/tags
# Will still fail if there is a docker container referencing image
Update for Docker 1.13+ [Since Jan 2017]
In Docker 1.13, we regrouped every command to sit under the logical object it’s interacting with
Basically, above commands could also be rewritten, more clearly, as:
docker container ls -a
docker image ls
docker container rm <container_id>
docker image rm <image_id>
Also, if you want to remove EVERYTHING you could use:
docker system prune -a
WARNING! This will remove:
all stopped containers
all networks not used by at least one container
all unused images
all build cache
First, remove the container names
$ sudo docker rm backstabbing_ritchie
The result
$ sudo docker rm backstabbing_ritchie
backstabbing_ritchie
delete the second part, which is listed on the container to be deleted
$ sudo docker rm drunk_feynman
drunk_feynman
Second, remove the container
$ sudo docker rmi training/webapp
The result
$ sudo docker rmi training/webapp
Untagged: training/webapp:latest
Deleted: 54bb4e8718e8600d78a5d7c62208c2f13c8caf0e4fe73d2bc0e474e93659c0b5
Deleted: f74dd040041eb4c032d3025fe38ea85de8075992bdce6789b694a44b20feb8de
Deleted: 7cbae69141977b99c44dc6957b032ad50c1379124d62b7d7d05ab7329b42348e
Deleted: abb991a4ed5e4cde2d9964aec4cccbe0015ba9cc9838b696e7a32e1ddf4a49bd
Deleted: 1952e3bf3d7e8e6a9b1e23bd4142e3c42ff7f4b7925122189704323593fd54ac
Deleted: f95ebd363bf27a7546deced7a41a4099334e37a3d2901fa3817e62bb1ade183f
Deleted: 20dd0c75901396d41a7b64d551ff04952084cc3947e66c67bae35759c80da338
Deleted: 2505b734adda3720799dde5004302f5edb3f2a2ff71438f6488b530b728ba666
Deleted: 2ee0b8f351f753f78f1178000ae37616eb5bf241d4ef041b612d58e1fd2aefdc
Deleted: 2ce633e3e9c9bd9e8fe7ade5984d7656ec3fc3994f05a97d5490190ef95bce8d
Deleted: 98b15185dba7f85308eb0e21196956bba653cf142b36dc08059b3468a01bf35d
Deleted: 515565c29c940355ec886c992231c6019a6cffa17ff1d2abdfc844867c9080c5
Deleted: 2880a3395eded9b748c94d27767e1e202f8d7cb06f1e40e18d1b1c77687aef77
Check the continer
$ sudo docker ps -as
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES SIZE
78479ffeba5c ubuntu "/bin/bash" 43 hours ago Exited (0) 43 hours ago sharp_wescoff 81 B (virtual 187.7 MB)
If you want to cleanup docker images and containers
CAUTION: this will flush everything
stop all containers
docker stop $(docker ps -a -q)
remove all containers
docker rm $(docker ps -a -q)
remove all images
docker rmi -f $(docker images -a -q)
you can use -f option to force delete the containers .
sudo docker rmi -f training/webapp
You may stop the containers using sudo docker stop training/webapp before deleting
If you have multiples docker containers launched, use this
$ docker rm $(docker ps -aq)
It will remove all the current dockers listed in the "ps -aq" command.
Source : aaam on https://github.com/docker/docker/issues/12487
1-Stop running container:
docker stop <container-id>
2-Remove container
docker rm <container-id>
3-Remove docker image
docker rmi <image-id>
list all your docker images:
docker images
list all existed docker containers:
docker ps -a
delete all the targeted containers, which is using the image that you want to delete:
docker rm <container-id>
delete the targeted image:
docker rmi <image-name:image-tag or image-id>
Noticed this is a 2-years old question, but still want to share my workaround for this particular question:
Firstly, run docker container ls -a to list all the containers you have and pinpoint the want you want to delete.
Secondly, delete the one with command docker container rm <CONTAINER ID> (If the container is currently running, you should stop it first, run docker container stop <CONTAINER ID> to gracefully stop the specified container, if it does not stop it for whatever the reason is, alternatively you can run docker container kill <CONTAINER ID> to force shutdown of the specified container).
Thirdly, remove the container by running docker container rm <CONTAINER ID>.
Lastly you can run docker image ls -a to view all the images and delete the one you want to by running docker image rm <hash>.
Deleting "network not found" in docker
Inspect the network which we are unable to delete
docker network inspect [<id> or <name>]
Disconnect the network
docker network disconnect -f [<networkID> or <networkName>] [<endpointName> or <endpointId>]
Delete unused networks
docker network prune
Remove docker images >
List all containers
docker container ls
List all images
docker image ls
Stop container by container id
docker container stop <container_id>
Remove container by container id
docker container rm <container_id>
If don't want stop and remove, can force remove
docker container rm -f <container_id>
Remove image
docker image rm <image_id>
Done!
Remove just the containers associated with a specific image
docker ps -a | grep training/webapp | cut -d ' ' -f 1 | xargs docker rm
ps -a: list all containers
grep training/webapp : filter out everything but the containers started from the training/webapp image
cut -d ' ' -f 1: list only the container ids (first field when delimited by space)
xargs docker rm : send the container id list output to the docker rm command to remove the container
Simply these two commands solve my issue.
Stop the particular container.
docker stop <container_id>
Forces removal of the image even if it is referenced in multiple repositories.
docker rmi -f <container_id>

docker: Error: failed to remove one or more images

I am not able to remove this image docker run -p 8080:80 bgruening/galaxy-stable
$ sudo docker ps -a -q
69a86acd37be
87540cb4904e
5c3e20ad2159
1426b69a9709
2cba8dcddd66
52b492693f21
$ sudo docker rmi 52b492693f21
Error response from daemon: No such image: 52b492693f21
FATA[0000] Error: failed to remove one or more images
How can I remove this image?
Thank you in advance.
You are listing the containers and trying to remove a container. Use docker images to list all the images and remove it with docker rmi IMAGEID with the proper id. If your intention is remove a container, not an image, use docker rm CONTAINERID
run the wrong command to list docker images, it should be:
docker images
then you should be fine to remove the images with docker rmi
But before to do that, make sure, the related containers all cleaned already.
docker ps -a
docker rm -f XXXXXX # -f means force removed if some of them are still in run mode.
In your case, I think that you want to stop and remove a container after you run it docker run -p 8080:80 bgruening/galaxy-stable
So you should run 2 commands below:
sudo docker stop 52b492693f21
sudo docker rm 52b492693f21
If you need to remove a image, you should use commands docker images to list all images, and docker rmi to remove a image.
Hope it helps

docker cannot remove images?

docker images
lists
test latest e10eb3d3a067 7 days ago 1.094 GB
But i tried to remove it using
docker rmi e10eb3d3a067
docker rmi -f <same_id>
It says, No such id :<different id, not the one i provided> and Error: failed to remove
Any suggestions to remove it?
I reffered this But i don't have any running contianers and no dependency between images that i want to remove.
Use the below command to list down all the containers
docker ps -a --format="container:{{.ID}} image:{{.Image}}"
Try to remove the image which you want
sudo docker rmi <image-id>
If you still get the same error then try to remove the containers associated with that image.
sudo docker rm <container-id>
Now try to remove the image

How does one remove a Docker image?

I'm running Docker under Vagrant under OS X 10.8.4 (Mountain Lion), and whenever I try to delete a saved image, I get an error:
$ docker rmi some-image-id
2013/07/15 hh:mm:ss unexpected JSON input
According to the rmi help, the proper syntax is docker rmi IMAGE [IMAGE...], and I'm not sure what to make of that.
How can I delete an image?
$ docker version
Client version: 0.4.8
Server version: 0.4.8
Go version: go1.1
 
$docker info
Containers: 1
Images: 3
Interestingly, when I run docker ps, no containers show up at all. Running docker images shows four (4) base images and one (1) node image.
Try docker rmi node. That should work.
Seeing all created containers is as simple as docker ps -a.
To remove all existing containers (not images!) run docker rm $(docker ps -aq)
The following are some of the ways to remove docker images/containers:
Remove single image
docker rmi image_name:version/image-id
Remove all images
docker rmi $(docker images -qf "dangling=true")
Kill containers and remove them:
docker rm $(docker kill $(docker ps -aq))
Note: Replace kill with stop for graceful shutdown
Remove all images except "my-image"
Use grep to remove all except my-image and ubuntu
docker rmi $(docker images | grep -v 'ubuntu\|my-image' | awk {'print $3'})
Or (without awk)
docker rmi $(docker images --quiet | grep -v $(docker images --quiet ubuntu:my-image))
Delete all docker containers
docker rm $(docker ps -a -q)
Delete all docker images
docker rmi $(docker images -q)
To remove an image from Docker using the image ID:
Get the list of all Images
docker images
Identify the image ID of the image you want to delete, for example:
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
kweku360/java latest 08d3a9b8e166 2 weeks ago 5.733 GB`
Finally remove the image using the image ID (only the first three digits are required)
docker rmi 08d
Image:
List images
docker images
Remove one image
docker rmi image_name
Force remove one image
docker rmi -f image_name
Container:
List all containers
docker ps -a
Remove one container
docker rm container_id
Force remove one container
docker rm -f container_id
Update, as commented by VonC in How to remove old Docker containers.
With Docker 1.13 (Q4 2016), you now have:
docker system prune will delete ALL unused data (i.e., in order: containers stopped, volumes without containers and images with no containers).
See PR 26108 and commit 86de7c0, which are introducing a few new commands to help facilitate visualizing how much space the Docker daemon data is taking on disk and allowing for easily cleaning up "unneeded" excess.
docker system prune
WARNING! This will remove:
- all stopped containers
- all volumes not used by at least one container
- all images without at least one container associated to them
Are you sure you want to continue? [y/N] y
Removing Containers
To remove a specific container
docker rm CONTAINER_ID CONTAINER_ID
For single image
docker rm 70c0e19168cf
For multiple images
docker rm 70c0e19168cf c2ce80b62174
Remove exited containers
docker ps -a -f status=exited
Remove all the containers
docker ps -q -a | xargs docker rm
Removing Images
docker rmi IMAGE_ID
Remove specific images
for single image
docker rmi ubuntu
for multiple images
docker rmi ubuntu alpine
Remove dangling images
Dangling images are layers that have no relationship to any tagged images as the Docker images are constituted of multiple images.
docker rmi -f $(docker images -f dangling=true -q)
Remove all Docker images
docker rmi -f $(docker images -a -q)
Removing Volumes
To list volumes, run docker volume ls
Remove a specific volume
docker volume rm VOLUME_NAME
Remove dangling volumes
docker volume rm $(docker volume ls -f dangling=true -q)
Remove a container and its volumes
docker rm -v CONTAINER_NAME
docker rm container_name
docker rmi image_name
docker help
rm Remove one or more containers
rmi Remove one or more images
docker rmi 91c95931e552
Error response from daemon: Conflict, cannot delete 91c95931e552 because the container 76068d66b290 is using it, use -f to force
FATA[0000] Error: failed to remove one or more images
Find container ID,
# docker ps -a
# docker rm daf644660736
First of all, we have to stop and remove the Docker containers which are attached with the Docker image that we are going to remove.
So for that, first
docker stop container-id - To stop the running container
docker rm container-id - To delete/remove the container
then,
docker rmi image-id - To delete/remove the image
For versions 1.13 and higher:
docker image rm [OPTIONS] IMAGE [IMAGE...]
Comparing:
the documention of docker image rm and
the documentation of docker rmi,
the [OPTIONS] seem to have no difference.
--force , -f Force removal of the image
--no-prune Do not delete untagged parents
From: Introducing Docker 1.13
CLI restructured
In Docker 1.13, we regrouped every command to sit under the logical object it’s interacting with. For example list and start of containers are now subcommands of docker container and history is a subcommand of docker image.
These changes let us clean up the Docker CLI syntax, improve help text and make Docker simpler to use. The old command syntax is still supported, but we encourage everybody to adopt the new syntax.
Docker provides some command to remove images.
Show/Remove Images:
docker images
docker images -a # All images
docker images --no-trunc # List the full length image IDs
docker images --filter "dangling=true" // Show unstage images
docker rmi $(docker images -f "dangling=true" -q) # Remove on unstages images
docker rmi <REPOSITORY> or <Image ID> # Remove a single image
docker image prune # Interactively remove dangling images
docker image prune -a # Remove all images
or
docker rmi -f $(sudo docker images -a -q)
Also, you can also use filter parameters to remove set of images at
once:
Example:
$docker images --filter "before=<hello-world>" // It will all images before hello-world
$docker images --filter "since=<hello-world>" // It will all images since hello-world
So you can delete that filter images like this:
docker rmi $(docker images --filter "since=<hello-world>")
docker rmi $(docker images --filter "before=<hello-world>")
Delete all of them using
Step 1: Kill all containers
for i in `sudo docker ps -a | awk '{ print $1 }'`; do sudo docker kill $i ; done
Step 2: RM them first
for i in `sudo docker ps -a | awk '{ print $1 }'`; do sudo docker rm $i ; done
Step 3: Delete the images using force
for i in `sudo docker images | awk '{ print $3}'`; do sudo docker rmi --force $i ; done
Use the step 1 in case you are getting error saying it cant be deleted owing to child dependencies
If you want to automatically/periodically clean up exited containers and remove images and volumes that aren't in use by a running container you can download the image meltwater/docker-cleanup.
I use this on production since we deploy several times a day on multiple servers, and I don't want to go to every server to clean up (that would be a pain).
Just run:
docker run -d -v /var/run/docker.sock:/var/run/docker.sock:rw -v /var/lib/docker:/var/lib/docker:rw --restart=unless-stopped meltwater/docker-cleanup:latest
It will run every 30 minutes (or however long you set it using DELAY_TIME=1800 option) and clean up exited containers and images.
More details: https://github.com/meltwater/docker-cleanup/blob/master/README.md
Here's a shell script to remove a tagged (named) image and it's containers.
Save as docker-rmi and run using 'docker-rmi my-image-name'
#!/bin/bash
IMAGE=$1
if [ "$IMAGE" == "" ] ; then
echo "Missing image argument"
exit 2
fi
docker ps -qa -f "ancestor=$IMAGE" | xargs docker rm
docker rmi $IMAGE
In my case the probleme is that I have tow images withe same name
the solution is to add the tag after the name or the id
sudo docker rmi <NAME>:<TAG>
ex:
sudo docker rmi php:7.0.4-fpm
Why nobody mentioned docker-compose! I 've just been using it for one week, and I cannot survive without it. All you need is writing a yml which takes only several minutes of studying, and then you are ready to go. It can boot images, containers (which are needed in so-called services) and let you review logs just like you use with docker native commands. Git it a try:
docker-compose up -d
docker-compose down --rmi 'local'
Before I used docker-compose, I wrote my own shell script, then I had to customize the script whenever needed especially when application architecture changed. Now I don't have to do this anymore, thanks to docker-compose.
For me the following worked fine:
> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
debian jessie 86baf4e8cde9 3 weeks ago 123MB
ubuntu yakkety 7d3f705d307c 3 weeks ago 107MB
alpine 3.5 074d602a59d7 7 weeks ago 3.99MB
Then go ahead and remove an image by running some like these:
> docker rmi debian:jessie
> docker rmi ubuntu:yakkety
> docker rmi alipine:3.5
List images:
ahanjura#ubuntu:~$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
88282f8eda00 19 seconds ago 308.5 MB
13e5d3d682f4 19 hours ago 663 MB
busybox2 latest 05fe66bb1144 20 hours ago 1.129 MB
ubuntu 16.04 00fd29ccc6f1 5 days ago 110.5 MB
ubuntu 14.04 67759a80360c 5 days ago 221.4 MB
python 2.7 9e92c8430ba0 7 days ago 680.7 MB
busybox latest 6ad733544a63 6 weeks ago 1.129 MB
ubuntu 16.10 7d3f705d307c 5 months ago 106.7 MB
Delete images:
ahanjura#ubuntu:~$ sudo docker rmi 88282f8eda00
Deleted: sha256:88282f8eda0036f85b5652c44d158308c6f86895ef1345dfa788318e6ba31194
Deleted: sha256:4f211a991fb392cd794bc9ad8833149cd9400c5955958c4017b1e2dc415e25e9
Deleted: sha256:8cc6917ac7f0dcb74969ae7958fe80b4a4ea7b3223fc888dfe1aef42f43df6f8
Deleted: sha256:b74a8932cff5e61c3fd2cc39de3c0989bdfd5c2e5f72b8f99f2807595f8ece43
ahanjura#ubuntu:~$ sudo docker rmi 13e5d3d682f4
Error response from daemon: conflict: unable to delete 13e5d3d682f4 (must be forced) - image is being used by stopped container 5593e25eb638
Delete by force:
ahanjura#ubuntu:~$ sudo docker rmi -f 13e5d3d682f4
Deleted: sha256:13e5d3d682f4de973780b35a3393c46eb314ef3db45d3ae83baf2dd9d702747e
Deleted: sha256:3ad9381c7041c03768ccd855ec86caa6bc0244223f10b0465c4898bdb21dc378
Deleted: sha256:5ccb917bce7bc8d3748eccf677d7b60dd101ed3e7fd2aedebd521735276606af
Deleted: sha256:18356d19b91f0abcc04496729c9a4c49e695dbfe3f0bb1c595f30a7d4d264ebf
First list all your images which are present by using :
docker images
For removing single image
Use docker rmi [image-name (or) image-id]
// This will remove only that specific image
For removing All images
Use docker rmi -f $(docker images -a -q)

Resources