Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,18 @@ func (c *DockerContainer) ContainerIP(ctx context.Context) (string, error) {
return "", err
}

return inspect.NetworkSettings.IPAddress, nil
ip := inspect.NetworkSettings.IPAddress
if ip != "" {
return ip, nil
}

for _, network := range inspect.NetworkSettings.Networks {
if network.IPAddress != "" {
return network.IPAddress, nil
}
}

return "", errors.New("IP address not found")
}

// NetworkAliases gets the aliases of the container for the networks it is attached to.
Expand Down
2 changes: 1 addition & 1 deletion logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ var Logger Logging = log.New(os.Stderr, "", log.LstdFlags)
// Logging defines the Logger interface
type Logging interface {
Printf(format string, v ...interface{})
}
}