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
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, rundocker container stop <CONTAINER ID>
to gracefully stop the specified container, if it does not stop it for whatever the reason is, alternatively you can rundocker 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 runningdocker image rm <hash>
.Remove just the containers associated with a specific image