kitchen-docker
kitchen-docker copied to clipboard
Docker images deletions fails when instances share the same image ID
Hi all!
Steps and Info. to reproduce the problem:
-
OS: Ubuntu 14.04
-
Clone
master
branch. -
Enable Docker images deletion:
remove_images: true
-
Create 2 instances.
kitchen create
-
Delete them
ktichen destroy
-
Note: Tested with instances of "AmazonLinux, Ubuntu 18,04 - 16.04 and Centos7"
I was working with the branch master
and I faced 2 errors, which I describe on the following.
- Error when creating instances
I first took the master
branch, to solve the issue commented in #338, but I got an error when creating the container for each Kitchen instance, which was reported here #355 and solved here #356.
Message: Error getting internal IP of Docker container
So I then took the Fork branch of #356 and this resolved the error.
- Error when deleting Docker images.
After setting remove_images: true
I got the following error when deleting the docker images.
Error response from daemon: conflict: unable to delete xxxx (cannot be forced) - image is being used by running container xxxxx**
After some debugging, I found that when creating instances with the same provisioning commands, Kitchen use the same image for such instances. And when running kitchen destroy
, Kitchen proceed by instance:image
pairs. But in this case what we have of such pairs is: (2 instances case)
- instance_1 : Image_0
- instance_2: Image_0
So both instances' containers used the same image.
When deleting, the process flow is as follows:
-
Delete instance_1: ✔️
-
Delete Corresponding Docker Image "Image_0": ❌
'image ID xx can't be deleted. still being used by a running container "instance_2'
-
Delete instance_2: ✔️
-
Delete Corresponding Docker Image "Image_0": ✔️
kr,
Rshad