From 74c29fde046149401a6b572b06c465b4d565a315 Mon Sep 17 00:00:00 2001 From: Tony Abboud Date: Thu, 12 Jan 2017 12:01:29 -0500 Subject: [PATCH] Add error checking for hostPort range This fix catches the case where there is a single container port and a dynamic host port and will fail out gracefully Example docker-compose.yml snippet: port: ports: - "8091-8093:8091" - "80:8080" Signed-off-by: Tony Abboud --- compose/convert/service.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/compose/convert/service.go b/compose/convert/service.go index 37f3ece403..a245987c8f 100644 --- a/compose/convert/service.go +++ b/compose/convert/service.go @@ -301,9 +301,11 @@ func convertEndpointSpec(source []string) (*swarm.EndpointSpec, error) { } for port := range ports { - portConfigs = append( - portConfigs, - opts.ConvertPortToPortConfig(port, portBindings)...) + portConfig, err := opts.ConvertPortToPortConfig(port, portBindings) + if err != nil { + return nil, err + } + portConfigs = append(portConfigs, portConfig...) } return &swarm.EndpointSpec{Ports: portConfigs}, nil