INNER CODE UNIT · Go
hostIsContainerLocal
docker/compose · relay/main.go:125
func hostIsContainerLocal(host string) bool {
if host == "localhost" {
return true
}
ip := net.ParseIP(host)
return ip != nil && (ip.IsLoopback() || ip.IsUnspecified())
}
// serve accepts connections until the listener closes. In-flight forwards
// join the WaitGroup, so on SIGTERM the process stops accepting (listeners
// close) but drains established connections until they finish — or until the
// engine's stop timeout escalates to SIGKILL.
func serve(ctx context.Context, listener net.Listener, upstream string, wg *sync.WaitGroup) {
backoff := 5 * time.Millisecond
for {
conn, err := listener.Accept()
if err != nil {
if ctx.Err() != nil {