THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Browse Source

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

tags/1.23.0^2
William Anthony Lapenna 4 months ago
parent
commit
61c38534a7
3 changed files with 17 additions and 7 deletions
  1. +10
    -2
      app/docker/services/networkService.js
  2. +5
    -4
      app/docker/views/containers/create/createContainerController.js
  3. +2
    -1
      webpack/webpack.common.js

+ 10
- 2
app/docker/services/networkService.js 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;


+ 5
- 4
app/docker/views/containers/create/createContainerController.js 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);
}


+ 2
- 1
webpack/webpack.common.js 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),


Loading…
Cancel
Save