Bläddra i källkod

[release] v0.11.0-unstable2

Yann Stepienik 1 år sedan
förälder
incheckning
2440a0a301
1 ändrade filer med 21 tillägg och 3 borttagningar
  1. 21 3
      src/docker/api_blueprint.go

+ 21 - 3
src/docker/api_blueprint.go

@@ -515,10 +515,28 @@ func CreateService(serviceRequest DockerServiceCreateRequest, OnLog func(string)
 
 			port, protocol := portStuff[0], portStuff[1]
 			
-			ports := strings.Split(port, ":")
+			hostPorts := []string{}
+			containerPorts := []string{}
 
-			hostPorts := generatePorts(ports[0])
-			containerPorts := generatePorts(ports[1])
+			// if port contains ->, it's ip bound
+			if strings.Contains(port, "->") {
+				ports := strings.Split(port, "->")
+				hostPortSlice = strings.Split(ports[0], ":")[1]
+				containerPortSlice = strings.Split(ports[1], ":")[1]
+
+				hostPorts = []string{
+					hostPortSlice[len(hostPortSlice)-1],
+				}
+
+				containerPorts = []string{
+					containerPortSlice[len(containerPortSlice)-1],
+				}				
+			} else {
+				ports := strings.Split(port, ":")
+
+				hostPorts = generatePorts(ports[0])
+				containerPorts = generatePorts(ports[1])
+			}
 
 			for i := 0; i < utils.Max(len(hostPorts), len(containerPorts)); i++ {
 				hostPort := hostPorts[i%len(hostPorts)]