Yelp / docker-custodian

Keep docker hosts tidy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

question: cannot delete because running container is using it

tony-kerz opened this issue · comments

love the utility (i almost think the functionality should be built into docker itself).

i'm seeing the following when running (is this normal, should it even be attempting this?):

Error calling remove_image alpine:latest 409 Client Error: Conflict ("Conflict, cannot delete 31f630c65071 because the running container a4241b3e14b6 is using it, stop it and use -f to force")

here are the vitals for the environment:

CoreOS stable (633.1.0)
$ docker version
Client version: 1.5.0
Client API version: 1.17
Go version (client): go1.3.3
Git commit (client): a8a31ef-dirty
OS/Arch (client): linux/amd64
Server version: 1.5.0
Server API version: 1.17
Go version (server): go1.3.3
Git commit (server): a8a31ef-dirty

regards,
tony.

I've seen this error a lot, so I guess it's normal. I believe it happens when a container is started after dcgc gets a list of containers (which is one of the first things it does), so dcgc thinks an image is not being used. Does that seem possible in your case?

For what it's worth, I encountered this as well when trying to use dcgc for the first time. I noticed in a dry-run that it wanted to delete two images that were definitely in use by actively running containers. Running it without a the dry-run flag caused it to print the same errors as the OP.

The end result seemed fine (it deleted everything I want, and couldn't delete those two images), but it does appear that something is a little off in the detection of which images are being used.

This was running on an Amazon ECS instance:

docker version
Client:
Version: 1.9.1
API version: 1.21
Go version: go1.4.2
Git commit: a34a1d5/1.9.1
Built:
OS/Arch: linux/amd64

Server:
Version: 1.9.1
API version: 1.21
Go version: go1.4.2
Git commit: a34a1d5/1.9.1
Built:
OS/Arch: linux/amd64