mirror of https://github.com/docker/docs.git
'docker pull' will download images from a public mirror by default
This commit is contained in:
parent
45c30b8eda
commit
3cfac8f335
|
@ -19,6 +19,8 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"bytes"
|
"bytes"
|
||||||
"sync"
|
"sync"
|
||||||
|
"net/url"
|
||||||
|
"path"
|
||||||
)
|
)
|
||||||
|
|
||||||
const VERSION = "0.0.1"
|
const VERSION = "0.0.1"
|
||||||
|
@ -307,11 +309,24 @@ func (srv *Server) CmdPull(stdin io.ReadCloser, stdout io.Writer, args ...string
|
||||||
if name == "" {
|
if name == "" {
|
||||||
return errors.New("Not enough arguments")
|
return errors.New("Not enough arguments")
|
||||||
}
|
}
|
||||||
resp, err := http.Get(args[0])
|
u, err := url.Parse(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
img, err := srv.images.Import(args[0], resp.Body, stdout, nil)
|
if u.Scheme == "" {
|
||||||
|
u.Scheme = "http"
|
||||||
|
}
|
||||||
|
// FIXME: hardcode a mirror URL that does not depend on a single provider.
|
||||||
|
if u.Host == "" {
|
||||||
|
u.Host = "s3.amazonaws.com"
|
||||||
|
u.Path = path.Join("/docker.io/images", u.Path)
|
||||||
|
}
|
||||||
|
fmt.Fprintf(stdout, "Downloading %s from %s...\n", name, u.String())
|
||||||
|
resp, err := http.Get(u.String())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
img, err := srv.images.Import(name, resp.Body, stdout, nil, compression)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue