From a06e1be2bc6862b6a82a8b01e94129ea80822e36 Mon Sep 17 00:00:00 2001 From: Akilan Selvacoumar Date: Fri, 8 Oct 2021 12:37:48 +0400 Subject: [PATCH] added mode to detect if a port is used or not in a container --- server/docker/docker.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/docker/docker.go b/server/docker/docker.go index 7a20ebc..0e816f7 100644 --- a/server/docker/docker.go +++ b/server/docker/docker.go @@ -48,6 +48,7 @@ type Port struct { InternalPort int `json:"InternalPort"` Type string `json:"Type"` ExternalPort int `json:"ExternalPort"` + IsUsed bool `json:"IsUsed"` Description string `json:"Description"` } @@ -124,7 +125,9 @@ func BuildRunContainer(NumPorts int, GPU string, ContainerName string) (*DockerV } // Allocate external ports to ports available in the ports.json file for i := range PortsInformation.PortSet { + // Setting external ports PortsInformation.PortSet[i].ExternalPort = OpenPorts[i] + PortsInformation.PortSet[i].IsUsed = true } //Length of Ports allocated from thr port file portFileLength := len(PortsInformation.PortSet) @@ -136,6 +139,7 @@ func BuildRunContainer(NumPorts int, GPU string, ContainerName string) (*DockerV TempPort.InternalPort = OpenPorts[portFileLength + i] TempPort.ExternalPort = OpenPorts[portFileLength + i] TempPort.Description = "Auto generated TCP port" + TempPort.IsUsed = false //Append temp port to port information PortsInformation.PortSet = append(PortsInformation.PortSet, TempPort) }