skip the volumes mounted when deleting the volumes of container.#2488
skip the volumes mounted when deleting the volumes of container.#2488crosbymichael merged 2 commits intomoby:masterfrom
Conversation
|
Hi, The best would be to not delete anything and to return an error to the client. Thanks |
|
Let me explain clearer. Suppose we launch a container by: And The behavior of original codes would try to trim the right of volumeId: Then the later code in same function: Because of returing the error, the other volumes of the container are not deleted. But the container is deleted already. So those volumes would be left in disk. Since the volume is mounted from external of the container (i.e. host), it would be best not to delete it (otherwise '/home/user/docker' would be removed). So this PR tries to skip those mounted volumes. The usage of TrimRight in original codes has problem. It will remove the 'er' from 'docker', for example. But I do not think that is what we want here. So this PR uses TrimSuffix instead. If there is no the suffix '/layer' in volumeId, we think it is a mounted volume and skip it in later deleting. |
|
ping @vieux |
There was a problem hiding this comment.
This most likely needs to be go fmt'd
|
Hi @viirya , sorry for the late reply. I understand your point. The best practice would be to use look as the Could you update your PR ? Thanks |
|
Hi @vieux, modified codes use Binds key to detect mounted volumes. Thanks. |
|
LGTM, ping @shykes @crosbymichael |
|
LGTM |
Skip the volumes mounted when deleting the volumes of container.
The volumes created by mounting with '-v' when running container are not correctly processed. Run 'docker rm' for such containers casts errors.
This PR skips those volumes when deleting containers to fix this problem.