From 43aaf94383c416eec9dc814363f551d1faaaae68 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Tue, 17 Nov 2015 16:31:47 -0800 Subject: [PATCH] Do Itoa once so line items are simpler --- client/driver/docker.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/client/driver/docker.go b/client/driver/docker.go index ecbfd053a..47cf662af 100644 --- a/client/driver/docker.go +++ b/client/driver/docker.go @@ -272,14 +272,15 @@ func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task, dri exposedPorts := map[docker.Port]struct{}{} for _, port := range network.ReservedPorts { - portStr := docker.Port(port.Value) + hostPortStr := strconv.Itoa(port.Value) + dockerPort := docker.Port(hostPortStr) - publishedPorts[portStr+"/tcp"] = []docker.PortBinding{docker.PortBinding{HostIP: network.IP, HostPort: strconv.Itoa(port.Value)}} - publishedPorts[portStr+"/udp"] = []docker.PortBinding{docker.PortBinding{HostIP: network.IP, HostPort: strconv.Itoa(port.Value)}} + publishedPorts[dockerPort+"/tcp"] = []docker.PortBinding{docker.PortBinding{HostIP: network.IP, HostPort: hostPortStr}} + publishedPorts[dockerPort+"/udp"] = []docker.PortBinding{docker.PortBinding{HostIP: network.IP, HostPort: hostPortStr}} d.logger.Printf("[DEBUG] driver.docker: allocated port %s:%d -> %d (static)\n", network.IP, port.Value, port.Value) - exposedPorts[portStr+"/tcp"] = struct{}{} - exposedPorts[portStr+"/udp"] = struct{}{} + exposedPorts[dockerPort+"/tcp"] = struct{}{} + exposedPorts[dockerPort+"/udp"] = struct{}{} d.logger.Printf("[DEBUG] driver.docker: exposed port %d\n", port.Value) }