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

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • 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. Examples of “shift” Command in Shell Scripts
  2. Understanding Positional Parameters (Passing Parameters/Arguments to Shell script)
  3. Understanding “docker stats” Command Output
  4. How to use shell aliases in Linux
  5. How to List / Search / Pull docker images on Linux
  6. Understanding Variables in Bash Shell Under Linux
  7. How to write multiple plays and per-play privilege escalation in Ansible
  8. New User Failed Run Kubectl with Error “The connection to the server xxx.xxx.xxx was refused – did you specify the right host or port?”
  9. How to use shell expansions for generating shell tokens under Linux
  10. How to schedule master node running pod/service as a worker node

You May Also Like

Primary Sidebar

Recent Posts

  • How to Configure Automatic Package Updates on the Server in CentOS/RHEL 8
  • FATAL: Error inserting rds_rdma
  • Failed to start LSB: Bring up/down networking – On restarting network service CentOS/RHEL (DHCP client)
  • How To Add Timestamps To dmesg Kernel Boot Log in CentOS/RHEL
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary