Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker prune stuck in "a prune operation is already running"

I run command docker system prune yesterday, it took some time and then my SSH session was disconnected from different reason.

Unfortunately I am getting now:

Error response from daemon: a prune operation is already running.

Obviously there is a lock and prune command is not running anymore.

Does anybody know how remove the lock without stopping and removing all containers?

EDIT: Created an issue in repo: https://github.com/moby/moby/issues/36447

like image 698
Martin Mika Avatar asked Feb 28 '18 08:02

Martin Mika


4 Answers

Restarting docker worked for me.

like image 127
Bhavani Avatar answered Oct 21 '22 01:10

Bhavani


This issue seems to occur when a container is not-responding to docker.

Here is how I've fixed it:

  1. First, find the non responding containers with: sudo docker inspect %CONTAINER ID%
  2. If a container do not respond, the inspect command will not return anything.
  3. One the %CONTAINER ID% not responding has been identified, find its correponding pid with: ps -aux | grep %CONTAINER ID%
  4. There should be a line looking like:

root 14931 0.0 0.0 7648 428 ? Sl Sep13 0:26 docker-containerd-shim -namespace moby -workdir /var/lib/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/3b0d4cba3f63a71fda99c76f3f777a156056e559fb034da4ed59c0aa340e5669 -address /var/run/docker/containerd/docker-containerd.sock -containerd-binary /usr/bin/docker-containerd -runtime-root /var/run/docker/runtime-runc

  1. Then, kill this service with kill -9 %PID%

Tip 1: There can be one or many container not responding

Tip 2: In order to avoid down-time, you can scale-up the service corresponding to the container that does not respond with a docker service scale ....

(my answer complements dparkar's.)

like image 24
KDemeul Avatar answered Oct 21 '22 00:10

KDemeul


In my case, it was not stuck, just taking a very long time to complete. It deleted 3500 images once finished!

like image 45
HostedMetrics.com Avatar answered Oct 21 '22 01:10

HostedMetrics.com


Working solution from the github issue :

doublemcz commented on Mar 14

I can confirm that prune stuck because of a non-responding container. When I kill the container first by kill -9 PROCESS_ID where the process Id I get from ps aux | grep docker-containerd-shim -namespace moby -workdir /var/lib/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/CONTAINER_ID

The problem is that you need to know that there is a container that does not respond on docker :-/ The container works (i.e. node.js works fine) but just docker is not able to even inspect it.

Btw this container should not even be there because we run docker service update... with the :latest image. Docker created another container and this was not killed. So there were two running containers with two different versions.

like image 33
dparkar Avatar answered Oct 21 '22 00:10

dparkar