I want to retrieve all docker images of a remote machine, so I am using docker/engine-api: https://github.com/docker/engine-api
I was successful in returning the docker images of my local machine with the following code:
package main
import (
"fmt"
"github.com/docker/engine-api/client"
"github.com/docker/engine-api/types"
"golang.org/x/net/context"
)
func main() {
defaultHeaders := map[string]string{"User-Agent": "engine-api-cli-1.0"}
cli, err := client.NewClient("unix:///var/run/docker.sock", "v1.22", nil, defaultHeaders)
if err != nil {
panic(err)
}
options := types.ContainerListOptions{All: true}
containers, err := cli.ContainerList(context.Background(), options)
if err != nil {
panic(err)
}
for _, c := range containers {
fmt.Println(c.ID)
}
}
But now does anybody know how can I retrieve the docker images of a remote machine given its address,username, and password
a better solution is to use the go-dockerclient in github which " provides support for docker's network API, which is a simple passthrough to the libnetwork remote API"
That kind of Unix socket is only accessible through proccesses in the same machine.
To access your docker from a remote machine you need to run it with a special configuration to run over ip.
This configuration is DOCKER_OPTS="-H <ip_address>:<port>"
(or -H 0.0.0.0:<port>
if you whant it to listen on all interfaces), and it depends the version you are running of docker where you must configure it.
Here you can find more information on where to configure DOCKER_OPTS depending on the operation system version.
Hope it helps!