• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Docker Troubleshooting – “conflict: unable to delete, image is being used by running container”

by admin

The problem

When you are trying to remove a Docker Image, you get an error as shown below.

# docker rmi d123f4e55e12
Error response from daemon: conflict: unable to delete d123f4e55e12 (cannot be forced) - image is being used by running container 0f1262bd1285

For this error to occur, there must be a container on the system that is dependent on the image. The error reports which container is using the image, remove the container before removing the image.

Solution

1. You have several Docker images pulled from the docker hub on to your Docker node. And you want to delete the centos image from the docker node.

# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
fedora              latest              422dc563ca32        3 days ago          252MB
ubuntu              latest              dd6f76d9cc90        13 days ago         122MB
hello-world         latest              725dcfab7d63        2 weeks ago         1.84kB
centos              latest              d123f4e55e12        2 weeks ago         197MB

2. To find which container is using the centos Image, use the below command.

# docker ps -a 
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                    PORTS               NAMES
0f1262bd1285        centos              "/bin/bash"         5 minutes ago       Up 5 minutes                                  dreamy_gates

As you can see in the output above, the Docker container “dreamy_gates” is using our centos image.

3. First we need to stop the container “dreamy_gates”. To do so use the command below:

# docker stop 0f1262bd1285
0f1262bd1285

4. Now you can delete the Docker container.

# docker rm 0f1262bd1285
0f1262bd1285

5. And finally, you can delete the docker image for centos.

# docker rmi d123f4e55e12
Untagged: centos:latest
Untagged: centos@sha256:4565fe2dd7f4770e825d4bd9c761a81b26e49cc9e3c9631c58cfc3188be9505a
Deleted: sha256:d123f4e55e1200156d9cbcf4421ff6d818576e4f1e29320a408c72f022cfd0b1
Deleted: sha256:cf516324493c00941ac20020801553e87ed24c564fb3f269409ad138945948d4

6. Verify that the image is deleted using the command “docker images”.

# docker images

Filed Under: DevOps, Docker

Some more articles you might also be interested in …

  1. Python Quadratic Formula
  2. How to Make a Variable read-only (constant) in Bash and Korn Shell
  3. How to update/add a file in the Docker Image
  4. How to configure docker to use proxy
  5. How to Disable Docker Process and docker0 Interface on CentOS/RHEL
  6. The Ultimate Beginner’s Guide to Static Website Hosting With Google Firebase (for FREE)
  7. The Ultimate Guide To Use VS Code With Windows Subsystem for Linux (WSL)
  8. Hello Newbies in Tech! Switching From Windows to Linux? Read This First
  9. How to List / Start / Stop / Delete docker Containers
  10. Strings and Variables in Python

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright