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

The Geek Diary

HowTos | Basics | Concepts

  • Solaris
    • Solaris 11
    • SVM
    • ZFS
    • Zones
    • LDOMs
    • Hardware
  • Linux
    • CentOS/RHEL 7
    • RHCSA notes
    • SuSE Linux Enterprise
    • Linux Services
  • VCS
    • VxVM
  • Interview Questions
  • oracle
    • ASM
    • mysql
    • RAC
    • oracle 12c
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Hadoop
    • Hortonworks HDP
      • HDPCA
    • Cloudera
      • CCA 131

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. Run Docker as a non-root user
  2. Beginners Guide to The Docker World
  3. Introduction to sed (Stream Editor) : Useful sed Command Examples
  4. How to Trace Python Scripts using trace.py
  5. How to install Docker on Mac
  6. How to install docker on CentOS / RHEL / Fedora
  7. How to Configure Nagios NRPE Client for System Monitoring (CentOS/RHEL)
  8. Understanding “docker stats” Command Output
  9. How to List / Search / Pull docker images on Linux
  10. How to configure docker to use proxy

You May Also Like

Primary Sidebar

Recent Posts

  • How to Pause and Resume Docker Containers
  • How to find docker storage device and its size (device mapper storage driver)
  • Understanding “docker stats” Command Output
  • ‘docker images’ command error – “Permission Denied”
  • Docker Basics – Expose ports, port binding and docker link
  • Archives
  • Contact Us
  • Copyright

© 2019 · The Geek Diary