Browse code

Merge pull request #3303 from crosbymichael/add-host-flag

Add DOCKER_HOST env var for client

Andy Rothfusz authored on 2013/12/31 08:54:37
Showing 2 changed files
... ...
@@ -52,8 +52,13 @@ func main() {
52 52
 		return
53 53
 	}
54 54
 	if flHosts.Len() == 0 {
55
-		// If we do not have a host, default to unix socket
56
-		flHosts.Set(fmt.Sprintf("unix://%s", docker.DEFAULTUNIXSOCKET))
55
+		defaultHost := os.Getenv("DOCKER_HOST")
56
+
57
+		if defaultHost == "" || *flDaemon {
58
+			// If we do not have a host, default to unix socket
59
+			defaultHost = fmt.Sprintf("unix://%s", docker.DEFAULTUNIXSOCKET)
60
+		}
61
+		flHosts.Set(defaultHost)
57 62
 	}
58 63
 
59 64
 	if *bridgeName != "" && *bridgeIp != "" {
... ...
@@ -52,6 +52,18 @@ To set the DNS server for all Docker containers, use ``docker -d -dns 8.8.8.8``.
52 52
 
53 53
 To run the daemon with debug output, use ``docker -d -D``.
54 54
 
55
+The docker client will also honor the ``DOCKER_HOST`` environment variable to set
56
+the ``-H`` flag for the client.  
57
+
58
+::
59
+ 
60
+        docker -H tcp://0.0.0.0:4243 ps
61
+        # or
62
+        export DOCKER_HOST="tcp://0.0.0.0:4243"
63
+        docker ps
64
+        # both are equal
65
+
66
+
55 67
 .. _cli_attach:
56 68
 
57 69
 ``attach``