diff --git a/src/compose/ports.ts b/src/compose/ports.ts index 8ed9c318..bf4cb396 100644 --- a/src/compose/ports.ts +++ b/src/compose/ports.ts @@ -139,6 +139,12 @@ export class PortMap { }, []); } + public static normaliseComposePorts(portMaps: PortMap[]): PortMap[] { + return _.sortBy(portMaps, p => { + return p.ports.internalStart; + }); + } + private parsePortString(portStr: string): void { const match = portStr.match(PORTS_REGEX); if (match == null) { diff --git a/src/compose/service.ts b/src/compose/service.ts index 44c856bb..c2613957 100644 --- a/src/compose/service.ts +++ b/src/compose/service.ts @@ -253,7 +253,9 @@ export class Service { let portMaps: PortMap[] = []; if (config.ports != null) { - portMaps = _.map(config.ports, p => new PortMap(p)); + portMaps = PortMap.normaliseComposePorts( + _.map(config.ports, p => new PortMap(p)), + ); } delete config.ports;