1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 13:29:41 +02:00

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

This commit is contained in:
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; return Network.disconnect({ id: networkId }, { Container: containerId, Force: force }).$promise;
}; };
service.connectContainer = function(networkId, containerId) { service.connectContainer = function(networkId, containerId, aliases) {
return Network.connect({ id: networkId }, { Container: containerId }).$promise; var payload = {
Container: containerId,
};
if (aliases) {
payload.EndpointConfig = {
Aliases: aliases,
}
}
return Network.connect({ id: networkId }, payload).$promise;
}; };
return service; return service;

View file

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

View file

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