about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-10-08 00:15:34 +0200
committerEmile <hanemile@protonmail.com>2019-10-08 00:15:34 +0200
commit5c2fbd5b08e3d637aedc97fe679aba029f50c024 (patch)
tree79dc27e92c0f38e5dc417ab9e81bd25ced3825e2
parenta280bf6cf496eed61c18cc1563c40836f5a6f93d (diff)
getting the ip address of the container and printing it
-rw-r--r--src/docker.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/docker.go b/src/docker.go
index 1dda5b2..7dfe584 100644
--- a/src/docker.go
+++ b/src/docker.go
@@ -120,6 +120,16 @@ func spawnCompanion(username string, accesscode string) {
 	connectContainerToNetwork(containerID, circusNetworkID)
 
 	log.Println("Container added to the circus network")
+
+	// Get IP Address of that container
+	inspectJSON, err := dockerCLI.ContainerInspect(dockerCtx, containerID)
+	if err != nil {
+		log.Println("inspectJsonErr: ", err)
+	}
+
+	fmt.Println("---")
+	fmt.Printf("%#v", inspectJSON.NetworkSettings.Networks)
+	fmt.Printf("companion IP: %#v", inspectJSON.NetworkSettings.Networks["circus"].IPAddress)
 }
 
 func generateSessionSalt() string {