diff --git a/app/components/createContainer/createContainerController.js b/app/components/createContainer/createContainerController.js index 77cefd4ac..b578a8bc0 100644 --- a/app/components/createContainer/createContainerController.js +++ b/app/components/createContainer/createContainerController.js @@ -299,7 +299,7 @@ function ($q, $scope, $state, $stateParams, $filter, Container, ContainerHelper, }; function createContainer(config, accessControlData) { - $q.when(!$scope.formValues.alwaysPull || ImageService.pullImage($scope.config.Image, $scope.formValues.Registry)) + $q.when(!$scope.formValues.alwaysPull || ImageService.pullImage($scope.config.Image, $scope.formValues.Registry, true)) .finally(function final() { ContainerService.createAndStartContainer(config) .then(function success(data) { diff --git a/app/components/image/imageController.js b/app/components/image/imageController.js index 5b8825bf4..fa2925b07 100644 --- a/app/components/image/imageController.js +++ b/app/components/image/imageController.js @@ -47,7 +47,7 @@ function ($scope, $stateParams, $state, $timeout, ImageService, RegistryService, RegistryService.retrieveRegistryFromRepository(repository) .then(function success(data) { var registry = data; - return ImageService.pullImage(repository, registry); + return ImageService.pullImage(repository, registry, false); }) .then(function success(data) { Notifications.success('Image successfully pulled', repository); diff --git a/app/components/images/imagesController.js b/app/components/images/imagesController.js index 6a1c56335..feb0f89ee 100644 --- a/app/components/images/imagesController.js +++ b/app/components/images/imagesController.js @@ -42,7 +42,7 @@ function ($scope, $state, ImageService, Notifications, Pagination, ModalService) $('#pullImageSpinner').show(); var image = $scope.formValues.Image; var registry = $scope.formValues.Registry; - ImageService.pullImage(image, registry) + ImageService.pullImage(image, registry, false) .then(function success(data) { Notifications.success('Image successfully pulled', image); $state.reload(); diff --git a/app/components/templates/templatesController.js b/app/components/templates/templatesController.js index b64eba6a4..e4ab1f384 100644 --- a/app/components/templates/templatesController.js +++ b/app/components/templates/templatesController.js @@ -69,7 +69,7 @@ function ($scope, $q, $state, $stateParams, $anchorScroll, $filter, ContainerSer generatedVolumeIds.push(volumeId); }); TemplateService.updateContainerConfigurationWithVolumes(templateConfiguration, template, data); - return ImageService.pullImage(template.Image, template.Registry); + return ImageService.pullImage(template.Image, { URL: template.Registry }, true); }) .then(function success(data) { return ContainerService.createAndStartContainer(templateConfiguration); diff --git a/app/services/docker/imageService.js b/app/services/docker/imageService.js index 415125f07..c3dbebb1e 100644 --- a/app/services/docker/imageService.js +++ b/app/services/docker/imageService.js @@ -54,14 +54,19 @@ angular.module('portainer.services') return deferred.promise; }; - - service.pullImage = function(image, registry) { + function pullImageAndIgnoreErrors(imageConfiguration) { var deferred = $q.defer(); - var imageDetails = ImageHelper.extractImageAndRegistryFromRepository(image); - var imageConfiguration = ImageHelper.createImageConfigForContainer(imageDetails.image, registry.URL); - var authenticationDetails = registry.Authentication ? RegistryService.encodedCredentials(registry) : ''; - HttpRequestHelper.setRegistryAuthenticationHeader(authenticationDetails); + Image.create({}, imageConfiguration).$promise + .finally(function final() { + deferred.resolve(); + }); + + return deferred.promise; + } + + function pullImageAndAcknowledgeErrors(imageConfiguration) { + var deferred = $q.defer(); Image.create({}, imageConfiguration).$promise .then(function success(data) { @@ -78,6 +83,18 @@ angular.module('portainer.services') }); return deferred.promise; + } + + service.pullImage = function(image, registry, ignoreErrors) { + var imageDetails = ImageHelper.extractImageAndRegistryFromRepository(image); + var imageConfiguration = ImageHelper.createImageConfigForContainer(imageDetails.image, registry.URL); + var authenticationDetails = registry.Authentication ? RegistryService.encodedCredentials(registry) : ''; + HttpRequestHelper.setRegistryAuthenticationHeader(authenticationDetails); + + if (ignoreErrors) { + return pullImageAndIgnoreErrors(imageConfiguration); + } + return pullImageAndAcknowledgeErrors(imageConfiguration); }; service.tagImage = function(id, image, registry) {