mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 15:29:42 +02:00
fix(services): let Docker automatically assign port when PublishedPort is not defined (#747)
This commit is contained in:
parent
9fda8f9c92
commit
ffca440135
2 changed files with 16 additions and 2 deletions
|
@ -83,8 +83,15 @@ function ($scope, $state, Service, Volume, Network, ImageHelper, Authentication,
|
||||||
function preparePortsConfig(config, input) {
|
function preparePortsConfig(config, input) {
|
||||||
var ports = [];
|
var ports = [];
|
||||||
input.Ports.forEach(function (binding) {
|
input.Ports.forEach(function (binding) {
|
||||||
if (binding.PublishedPort && binding.TargetPort) {
|
var port = {
|
||||||
ports.push({ PublishedPort: +binding.PublishedPort, TargetPort: +binding.TargetPort, Protocol: binding.Protocol });
|
Protocol: binding.Protocol
|
||||||
|
};
|
||||||
|
if (binding.TargetPort) {
|
||||||
|
port.TargetPort = +binding.TargetPort;
|
||||||
|
if (binding.PublishedPort) {
|
||||||
|
port.PublishedPort = +binding.PublishedPort;
|
||||||
|
}
|
||||||
|
ports.push(port);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
config.EndpointSpec.Ports = ports;
|
config.EndpointSpec.Ports = ports;
|
||||||
|
|
|
@ -197,6 +197,13 @@ function ($scope, $stateParams, $state, $location, $anchorScroll, Service, Servi
|
||||||
MaxAttempts: service.RestartMaxAttempts,
|
MaxAttempts: service.RestartMaxAttempts,
|
||||||
Window: service.RestartWindow
|
Window: service.RestartWindow
|
||||||
};
|
};
|
||||||
|
|
||||||
|
service.Ports.forEach(function (binding) {
|
||||||
|
if (binding.PublishedPort === null || binding.PublishedPort === '') {
|
||||||
|
delete binding.PublishedPort;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
config.EndpointSpec = {
|
config.EndpointSpec = {
|
||||||
Mode: config.EndpointSpec.Mode || 'vip',
|
Mode: config.EndpointSpec.Mode || 'vip',
|
||||||
Ports: service.Ports
|
Ports: service.Ports
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue