Bladeren bron

dont restart container unless new hash

reid 2 jaren geleden
bovenliggende
commit
e4ca3ed266
1 gewijzigde bestanden met toevoegingen van 3 en 2 verwijderingen
  1. 3 2
      docker/docker.go

+ 3 - 2
docker/docker.go

@@ -200,8 +200,9 @@ func StartContainer(containerName string, containerType string) (structs.Contain
 		// if container is running, check the image tag
 		currentImage := existingContainer.Image
 		currentTag := strings.Split(currentImage, ":")[1]
-		if currentTag != desiredTag {
-			// if the tags don't match, recreate the container with the new tag
+		logger.Info(fmt.Sprintf("New %s image: %s@sha256:%s", containerType, desiredTag, desiredHash))
+		if currentTag != desiredTag || existingContainer.ImageID != desiredHash {
+			// if the hashes don't match, recreate the container with the new one
 			err := cli.ContainerRemove(ctx, containerName, types.ContainerRemoveOptions{Force: true})
 			if err != nil {
 				return containerState, err