Skip to content

Commit

Permalink
prefer http (80 and 8080) ports when choosing the container port
Browse files Browse the repository at this point in the history
  • Loading branch information
paulll committed Mar 16, 2020
1 parent d9a321a commit d2cefd1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d2cefd1

Please sign in to comment.