fix(container-creation): preserve network aliases (#3401)

pull/3403/head
William 2019-11-28 09:35:14 +13:00 committed by Anthony Lapenna
parent 7f54584ed6
commit 61c38534a7
3 changed files with 17 additions and 7 deletions

View File

@ -71,8 +71,16 @@ angular.module('portainer.docker')
return Network.disconnect({ id: networkId }, { Container: containerId, Force: force }).$promise;
};
service.connectContainer = function(networkId, containerId) {
return Network.connect({ id: networkId }, { Container: containerId }).$promise;
service.connectContainer = function(networkId, containerId, aliases) {
var payload = {
Container: containerId,
};
if (aliases) {
payload.EndpointConfig = {
Aliases: aliases,
}
}
return Network.connect({ id: networkId }, payload).$promise;
};
return service;

View File

@ -208,7 +208,8 @@ function ($q, $scope, $async, $state, $timeout, $transition$, $filter, Container
IPAMConfig: {
IPv4Address: $scope.formValues.IPv4,
IPv6Address: $scope.formValues.IPv6
}
},
Aliases: _.without($scope.config.NetworkingConfig.EndpointsConfig[networkMode].Aliases, $scope.config.Hostname)
};
$scope.formValues.ExtraHosts.forEach(function (v) {
@ -780,9 +781,9 @@ function ($q, $scope, $async, $state, $timeout, $transition$, $filter, Container
return $q.when();
}
var connectionPromises = Object.keys($scope.extraNetworks).map(function (networkName) {
return NetworkService.connectContainer(networkName, newContainerId);
});
var connectionPromises = _.forOwn($scope.extraNetworks, function (network, networkName) {
return NetworkService.connectContainer(networkName, newContainerId, _.without(network.Aliases, $scope.config.Hostname));
});
return $q.all(connectionPromises);
}

View File

@ -94,7 +94,8 @@ module.exports = {
// new BundleAnalyzerPlugin()
new LodashModuleReplacementPlugin({
shorthands: true,
collections: true
collections: true,
paths: true
}),
new DefinePlugin({
__CONFIG_GA_ID: JSON.stringify(pkg.config.GA_ID),