From 7104806ad1a86feb6835aafea5d40eedf8bc4c4f Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Thu, 2 Jun 2016 14:55:12 -0300 Subject: [PATCH] Correctly compare container image name on cleanup Docker 1.10 sends containerInfo.Image without the ":latest", so the image name doesn't match the app's imageId. This fix first splits the image name into repo and tag and then rebuilds it to include ":latest" when appropriate. Should avoid removing containers when using resin-sync. --- CHANGELOG.md | 1 + src/docker-utils.coffee | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfe5b930..25b50b2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +* Correctly compare container image name on cleanup [Pablo] * Log useful supervisor info to stdout/stderr [Kostas] # v1.10.0 diff --git a/src/docker-utils.coffee b/src/docker-utils.coffee index c5f5443f..457bba3e 100644 --- a/src/docker-utils.coffee +++ b/src/docker-utils.coffee @@ -200,13 +200,16 @@ do -> docker.listContainersAsync(all: true) .filter (containerInfo) -> # Do not remove user apps. - if _.contains(appTags, containerInfo.Image) - return false - if _.contains(locallyCreatedTags, containerInfo.Image) - return false - if !_.contains(supervisorTags, containerInfo.Image) - return true - return containerHasExited(containerInfo.Id) + getRepoAndTag(containerInfo.Image) + .then ({ repo, tag }) -> + repoTag = buildRepoTag(repo, tag) + if _.contains(appTags, repoTag) + return false + if _.contains(locallyCreatedTags, repoTag) + return false + if !_.contains(supervisorTags, repoTag) + return true + return containerHasExited(containerInfo.Id) .map (containerInfo) -> docker.getContainer(containerInfo.Id).removeAsync() .then ->