support boot2docker via environment variables
This commit is contained in:
parent
7aace0ee2a
commit
8c98858fcb
1 changed files with 20 additions and 3 deletions
19
images.go
19
images.go
|
@ -8,6 +8,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -53,10 +54,26 @@ func (x *ImagesCommand) Execute(args []string) error {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// grab directly from docker daemon
|
// grab directly from docker daemon
|
||||||
client, err := docker.NewClient("unix:///var/run/docker.sock")
|
endpoint := os.Getenv("DOCKER_HOST")
|
||||||
|
if len(endpoint) == 0 {
|
||||||
|
endpoint = "unix:///var/run/docker.sock"
|
||||||
|
}
|
||||||
|
|
||||||
|
var client *docker.Client
|
||||||
|
if dockerCertPath := os.Getenv("DOCKER_CERT_PATH"); len(dockerCertPath) > 0 {
|
||||||
|
cert := path.Join(dockerCertPath, "cert.pem")
|
||||||
|
key := path.Join(dockerCertPath, "key.pem")
|
||||||
|
ca := path.Join(dockerCertPath, "ca.pem")
|
||||||
|
client, err = docker.NewTLSClient(endpoint, cert, key, ca)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
client, err = docker.NewClient(endpoint)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
clientImages, err := client.ListImages(docker.ListImagesOptions{All: true})
|
clientImages, err := client.ListImages(docker.ListImagesOptions{All: true})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue