| ... | ... |
@@ -18,8 +18,9 @@ import ( |
| 18 | 18 |
) |
| 19 | 19 |
|
| 20 | 20 |
const APIVERSION = 1.4 |
| 21 |
-const DEFAULTHTTPHOST string = "127.0.0.1" |
|
| 22 |
-const DEFAULTHTTPPORT int = 4243 |
|
| 21 |
+const DEFAULTHTTPHOST = "127.0.0.1" |
|
| 22 |
+const DEFAULTHTTPPORT = 4243 |
|
| 23 |
+const DEFAULTUNIXSOCKET = "/var/run/docker.sock" |
|
| 23 | 24 |
|
| 24 | 25 |
func hijackServer(w http.ResponseWriter) (io.ReadCloser, io.Writer, error) {
|
| 25 | 26 |
conn, _, err := w.(http.Hijacker).Hijack() |
| ... | ... |
@@ -977,9 +978,8 @@ func ListenAndServe(proto, addr string, srv *Server, logging bool) error {
|
| 977 | 977 |
if e != nil {
|
| 978 | 978 |
return e |
| 979 | 979 |
} |
| 980 |
- //as the daemon is launched as root, change to permission of the socket to allow non-root to connect |
|
| 981 | 980 |
if proto == "unix" {
|
| 982 |
- os.Chmod(addr, 0777) |
|
| 981 |
+ os.Chmod(addr, 0700) |
|
| 983 | 982 |
} |
| 984 | 983 |
httpSrv := http.Server{Addr: addr, Handler: r}
|
| 985 | 984 |
return httpSrv.Serve(l) |
| ... | ... |
@@ -33,7 +33,7 @@ func main() {
|
| 33 | 33 |
flGraphPath := flag.String("g", "/var/lib/docker", "Path to graph storage base dir.")
|
| 34 | 34 |
flEnableCors := flag.Bool("api-enable-cors", false, "Enable CORS requests in the remote api.")
|
| 35 | 35 |
flDns := flag.String("dns", "", "Set custom dns servers")
|
| 36 |
- flHosts := docker.ListOpts{fmt.Sprintf("tcp://%s:%d", docker.DEFAULTHTTPHOST, docker.DEFAULTHTTPPORT)}
|
|
| 36 |
+ flHosts := docker.ListOpts{fmt.Sprintf("unix://%s", docker.DEFAULTUNIXSOCKET)}
|
|
| 37 | 37 |
flag.Var(&flHosts, "H", "tcp://host:port to bind/connect to or unix://path/to/socket to use") |
| 38 | 38 |
flag.Parse() |
| 39 | 39 |
if len(flHosts) > 1 {
|
| ... | ... |
@@ -15,7 +15,7 @@ Docker Remote API |
| 15 | 15 |
===================== |
| 16 | 16 |
|
| 17 | 17 |
- The Remote API is replacing rcli |
| 18 |
-- Default port in the docker daemon is 4243 |
|
| 18 |
+- By default the Docker daemon listens on unix:///var/run/docker.sock and the client must have root access to interact with the daemon |
|
| 19 | 19 |
- The API tends to be REST, but for some complex commands, like attach |
| 20 | 20 |
or pull, the HTTP connection is hijacked to transport stdout stdin |
| 21 | 21 |
and stderr |