I have a simple Go application running inside a docker container. I wish to get the container IP of that container inside the Go application itself. How can I do that? I am a newbie so please help me out, if this question sounds silly
Asked
Active
Viewed 1,681 times
1 Answers
3
You can get the hostname using os.hostname()
function.
Below golang code can give you some idea
package main
import (
"fmt"
"os"
)
func main() {
containerHostname, err := os.Hostname()
}
containerHostname variable will have the hostname of the container.

Mehant Kammakomati
- 852
- 1
- 8
- 25