Skip to content
This repository has been archived by the owner on Nov 23, 2019. It is now read-only.

How to connect to a remote socket in docker/engine-api? #293

Open
sms81 opened this issue Jun 30, 2016 · 2 comments
Open

How to connect to a remote socket in docker/engine-api? #293

sms81 opened this issue Jun 30, 2016 · 2 comments

Comments

@sms81
Copy link

sms81 commented Jun 30, 2016

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?

@ehazlett
Copy link
Contributor

ehazlett commented Jul 6, 2016

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 .

@fsoppelsa
Copy link

@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)
    }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants