I have a golang script that calls an HTTP API. Everything works great when I run it on my development computer. Once I create the container and run it I get an EOF at the end of the URL on panic. I have read a lot of issues like this and have tried everyone I see. I added a ca-certificates.crt from my host machine to the container to /etc/ssl/certs/. I set the request close to true, I have disabled Keep-Alive and Compression. All of these steps worked for others on other posts. Any help appreciated.
I got my certfile from https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt
I am running go version go1.9.2 darwin/amd64 and the container is on a ubuntu 16.04 host.
client := &http.Client{Timeout: 30 * time.Second, Transport: &http.Transport{
DisableCompression:true,
DisableKeepAlives: true,
}}
url := "https://myapiurl.com"
req, err := http.NewRequest("POST", url, bytes.NewBuffer(mybodybytes))
req.Close = true
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Panic(err) // Panics Here
}
defer resp.Body.Close()
...
Dockerfile:
FROM scratch
ADD ca-certificates.crt /etc/ssl/certs/
ADD myservice /
CMD ["/myservice"]