From d2cefd18432192bf6d8c6957dab5c071b5a0498f Mon Sep 17 00:00:00 2001 From: paulll Date: Tue, 17 Mar 2020 02:19:17 +0300 Subject: [PATCH] prefer http (80 and 8080) ports when choosing the container port --- lib/docker.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/docker.js b/lib/docker.js index 69a12ad..a4c87c1 100644 --- a/lib/docker.js +++ b/lib/docker.js @@ -144,7 +144,12 @@ function isMatchingImageName(targetName, imageName) { function containerPort(dolphin, containerId) { return dolphin.containers.inspect(containerId).then(function (container) { - var port = Object.keys(container.NetworkSettings.Ports)[0].split('/')[0]; + var portPriority = ['8080', '80']; // 80, then 8080, then others + var port = Object.keys(container.NetworkSettings.Ports) + .map(function (x) { return x.split('/')[0]}) + .sort(function(port_a, port_b) { + return portPriority.indexOf(port_b) - portPriority.indexOf(port_a) + })[0]; var netNames = Object.keys(container.NetworkSettings.Networks); if (netNames.length === 1) {