@@ -63,7 +63,7 @@ func SetupElastic() (*elastic.Client, func(), error) {
6363 "ES_HEAP_SIZE=128m" ,
6464 },
6565 }, func (config * docker.HostConfig ) {
66- config .AutoRemove = true
66+ config .AutoRemove = false
6767 config .RestartPolicy = docker.RestartPolicy {Name : "no" }
6868 // Tmpfs is much faster than the default docker mounts.
6969 config .Mounts = []docker.HostMount {
@@ -103,17 +103,29 @@ func SetupElastic() (*elastic.Client, func(), error) {
103103 return nil , cleanup , err
104104 }
105105
106- // Increase retry timeout to 3 minutes (default is 1 minute)
107- pool .MaxWait = 3 * time .Minute
106+ // Increase retry timeout (default is 1 minute)
107+ pool .MaxWait = 1 * time .Minute
108+
109+ // Log network debugging info
110+ log .Infof ("Container ID: %s" , resource .Container .ID )
111+ log .Infof ("Container IPAddress: %s" , resource .Container .NetworkSettings .IPAddress )
112+ log .Infof ("Container Gateway: %s" , resource .Container .NetworkSettings .Gateway )
113+ log .Infof ("Mapped port 9200/tcp: %s" , resource .GetPort ("9200/tcp" ))
114+ for netName , netSettings := range resource .Container .NetworkSettings .Networks {
115+ log .Infof ("Network %s: Gateway=%s, IPAddress=%s" , netName , netSettings .Gateway , netSettings .IPAddress )
116+ }
108117
109118 clientPort := "9200"
119+ esHost := resource .Container .NetworkSettings .IPAddress
120+ esURL := fmt .Sprintf ("http://%s:%s" , esHost , clientPort )
121+ log .Infof ("Will attempt to connect to Elasticsearch at: %s" , esURL )
122+
110123 var client * elastic.Client
111124 err = pool .Retry (func () error {
112125 var err error
113- client , err = connectElastic (fmt .Sprintf ("http://%s:%s" ,
114- resource .Container .NetworkSettings .IPAddress , clientPort ), "elastic" , esPass )
126+ client , err = connectElastic (esURL , "elastic" , esPass )
115127 if err != nil {
116- log .WithError (err ).Errorf ("Failed to connect to elasticsearch." )
128+ log .WithError (err ).Errorf ("Failed to connect to elasticsearch at %s" , esURL )
117129 }
118130 return err
119131 })
0 commit comments