engine-api
engine-api copied to clipboard
How to connect to a remote socket in docker/engine-api?
I want to retrieve all docker images of a remote machine, I was successful in returning the docker images of my local machine with the code provided in the Readme.md file, but the question is how can i retrieve docker images of a remote machine given its address,username, and password?
Currently the way to access a remote Docker host is via TCP. It is strongly recommended to use TLS.
Here are some docs to configure remote access for a Docker Engine: https://docs.docker.com/engine/security/https/. You can then connect using something like tcp://<ip>:2376
.
@sms81 does this help?
var c *http.Client
var host = "tcp://192.168.99.100:2376"
var path = "/path/to/.docker/machine/machines/mymachine/"
securityOptions := tlsconfig.Options{
CAFile: filepath.Join(path, "ca.pem"),
CertFile: filepath.Join(path, "cert.pem"),
KeyFile: filepath.Join(path, "key.pem"),
InsecureSkipVerify: true,
}
tlsc, err := tlsconfig.Client(securityOptions)
if err != nil {
return
}
c = &http.Client{
Transport: &http.Transport{
TLSClientConfig: tlsc,
},
}
defaultHeaders := map[string]string{"User-Agent": "engine-api-cli-1.0"}
cli, err := client.NewClient(host, "v1.24", c, defaultHeaders) // engine 1.12
if err != nil {
panic(err)
}