36

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

Martin Mika
  • 581
  • 1
  • 4
  • 12

7 Answers7

17

Restarting docker worked for me.

Bhavani
  • 195
  • 1
  • 10
12

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.)

KDemeul
  • 121
  • 1
  • 5
5

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

HostedMetrics.com
  • 3,525
  • 3
  • 26
  • 31
  • 7
    I had this same issue - you can run `docker system info` in a separate terminal session to check if the number of containers/images is going down. – Wet Noodles Feb 09 '21 at 13:58
1

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.

dparkar
  • 1,934
  • 2
  • 22
  • 52
0

In my case these steps helped (I have hundreds of containers, so I was not able to identify the bad ones).
I'm using minikube.

  1. Ensure that all your stuff running in deployments/replicasets.
  2. systemctl restart docker (this command runs forever for me)
  3. Now it is possible to identify the dangling processes via ps auxf. All other containers are stopped.
  4. Kill them via kill -9 <PID>
  5. Now rerun systemctl restart docker. It should now working correctly.
  6. Kubernetes will bring back all pods correctly. Just give it some time (it will restart pods multiple times)
akop
  • 5,981
  • 6
  • 24
  • 51
0

Easy way to fix this issue Question:
enter image description here

Answer: service docker restart
enter image description here

Done:
enter image description here

Willie Cheng
  • 7,679
  • 13
  • 55
  • 68
0

Restart the docker service. It is worked for me.

sudo systemctl restart docker.service

Amjed saleel
  • 348
  • 1
  • 3
  • 15