fix(container-creation): preserve aliases if null (#3405)

* fix(container-creation): preserve aliases if null

* Update app/docker/views/containers/create/createContainerController.js
pull/3408/head
William 2019-11-29 09:21:23 +13:00 committed by Anthony Lapenna
parent 5ab63bd151
commit dd0c80e915
1 changed files with 11 additions and 9 deletions

View File

@ -203,19 +203,18 @@ function ($q, $scope, $async, $state, $timeout, $transition$, $filter, Container
config.HostConfig.NetworkMode = networkMode; config.HostConfig.NetworkMode = networkMode;
config.MacAddress = $scope.formValues.MacAddress; config.MacAddress = $scope.formValues.MacAddress;
let aliases = [];
if (networkMode && _.has($scope.config.NetworkingConfig.EndpointsConfig[networkMode], 'Aliases')){
aliases = _.without($scope.config.NetworkingConfig.EndpointsConfig[networkMode].Aliases, $scope.config.Hostname);
}
config.NetworkingConfig.EndpointsConfig[networkMode] = { config.NetworkingConfig.EndpointsConfig[networkMode] = {
IPAMConfig: { IPAMConfig: {
IPv4Address: $scope.formValues.IPv4, IPv4Address: $scope.formValues.IPv4,
IPv6Address: $scope.formValues.IPv6 IPv6Address: $scope.formValues.IPv6
}, }
Aliases: aliases
}; };
if (networkMode && _.get($scope.config.NetworkingConfig.EndpointsConfig[networkMode], 'Aliases')){
var aliases = $scope.config.NetworkingConfig.EndpointsConfig[networkMode].Aliases;
config.NetworkingConfig.EndpointsConfig[networkMode].Aliases = _.filter(aliases, (o) => { return !_.startsWith($scope.fromContainer.Id,o)});
}
$scope.formValues.ExtraHosts.forEach(function (v) { $scope.formValues.ExtraHosts.forEach(function (v) {
if (v.value) { if (v.value) {
config.HostConfig.ExtraHosts.push(v.value); config.HostConfig.ExtraHosts.push(v.value);
@ -781,7 +780,10 @@ function ($q, $scope, $async, $state, $timeout, $transition$, $filter, Container
} }
var connectionPromises = _.forOwn($scope.extraNetworks, function (network, networkName) { var connectionPromises = _.forOwn($scope.extraNetworks, function (network, networkName) {
return NetworkService.connectContainer(networkName, newContainerId, _.without(network.Aliases, $scope.config.Hostname)); if (_.has(network, 'Aliases')) {
var aliases = _.filter(network.Aliases, (o) => { return !_.startsWith($scope.fromContainer.Id,o)})
}
return NetworkService.connectContainer(networkName, newContainerId, aliases);
}); });
return $q.all(connectionPromises); return $q.all(connectionPromises);