Skip to content

Commit d2cefd1

Browse files
committed
prefer http (80 and 8080) ports when choosing the container port
1 parent d9a321a commit d2cefd1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/docker.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@ function isMatchingImageName(targetName, imageName) {
144144

145145
function containerPort(dolphin, containerId) {
146146
return dolphin.containers.inspect(containerId).then(function (container) {
147-
var port = Object.keys(container.NetworkSettings.Ports)[0].split('/')[0];
147+
var portPriority = ['8080', '80']; // 80, then 8080, then others
148+
var port = Object.keys(container.NetworkSettings.Ports)
149+
.map(function (x) { return x.split('/')[0]})
150+
.sort(function(port_a, port_b) {
151+
return portPriority.indexOf(port_b) - portPriority.indexOf(port_a)
152+
})[0];
148153

149154
var netNames = Object.keys(container.NetworkSettings.Networks);
150155
if (netNames.length === 1) {

0 commit comments

Comments
 (0)