Browse code

Merge pull request #26882 from runcom/proxy-path

Specify userland proxy path

Vincent Demeester authored on 2016/10/07 16:44:39
Showing 6 changed files
... ...
@@ -50,6 +50,7 @@ type bridgeConfig struct {
50 50
 	EnableIPForward             bool   `json:"ip-forward,omitempty"`
51 51
 	EnableIPMasq                bool   `json:"ip-masq,omitempty"`
52 52
 	EnableUserlandProxy         bool   `json:"userland-proxy,omitempty"`
53
+	UserlandProxyPath           string `json:"userland-proxy-path,omitempty"`
53 54
 	DefaultIP                   net.IP `json:"ip,omitempty"`
54 55
 	IP                          string `json:"bip,omitempty"`
55 56
 	FixedCIDRv6                 string `json:"fixed-cidr-v6,omitempty"`
... ...
@@ -84,6 +85,7 @@ func (config *Config) InstallFlags(flags *pflag.FlagSet) {
84 84
 	flags.BoolVar(&config.bridgeConfig.InterContainerCommunication, "icc", true, "Enable inter-container communication")
85 85
 	flags.Var(opts.NewIPOpt(&config.bridgeConfig.DefaultIP, "0.0.0.0"), "ip", "Default IP when binding container ports")
86 86
 	flags.BoolVar(&config.bridgeConfig.EnableUserlandProxy, "userland-proxy", true, "Use userland proxy for loopback traffic")
87
+	flags.StringVar(&config.bridgeConfig.UserlandProxyPath, "userland-proxy-path", "", "Path to the userland proxy binary")
87 88
 	flags.BoolVar(&config.EnableCors, "api-enable-cors", false, "Enable CORS headers in the remote API, this is deprecated by --api-cors-header")
88 89
 	flags.MarkDeprecated("api-enable-cors", "Please use --api-cors-header")
89 90
 	flags.StringVar(&config.CgroupParent, "cgroup-parent", "", "Set parent cgroup for all containers")
... ...
@@ -662,7 +662,8 @@ func driverOptions(config *Config) []nwconfig.Option {
662 662
 	bridgeConfig := options.Generic{
663 663
 		"EnableIPForwarding":  config.bridgeConfig.EnableIPForward,
664 664
 		"EnableIPTables":      config.bridgeConfig.EnableIPTables,
665
-		"EnableUserlandProxy": config.bridgeConfig.EnableUserlandProxy}
665
+		"EnableUserlandProxy": config.bridgeConfig.EnableUserlandProxy,
666
+		"UserlandProxyPath":   config.bridgeConfig.UserlandProxyPath}
666 667
 	bridgeOption := options.Generic{netlabel.GenericData: bridgeConfig}
667 668
 
668 669
 	dOptions := []nwconfig.Option{}
... ...
@@ -146,6 +146,9 @@ For example, to install the binaries in `/usr/bin`:
146 146
 $ mv docker/* /usr/bin/
147 147
 ```
148 148
 
149
+> **Note**: Depending on your current setup, you can specify custom paths
150
+> for some of the binaries provided.
151
+
149 152
 > **Note**: If you already have Engine installed on your host, make sure you
150 153
 > stop Engine before installing (`killall docker`), and install the binaries
151 154
 > in the same location. You can find the location of the current installation
... ...
@@ -78,6 +78,7 @@ Options:
78 78
       --tlskey=~/.docker/key.pem             Path to TLS key file
79 79
       --tlsverify                            Use TLS and verify the remote
80 80
       --userland-proxy=true                  Use userland proxy for loopback traffic
81
+      --userland-proxy-path=""               Path to the userland proxy binary
81 82
       --userns-remap                         User/Group setting for user namespaces
82 83
       -v, --version                          Print version information and quit
83 84
 ```
... ...
@@ -1149,6 +1150,7 @@ This is a full example of the allowed configuration options on Linux:
1149 1149
 	"ip-forward": false,
1150 1150
 	"ip-masq": false,
1151 1151
 	"userland-proxy": false,
1152
+	"userland-proxy-path": "/usr/libexec/docker-proxy",
1152 1153
 	"ip": "0.0.0.0",
1153 1154
 	"bridge": "",
1154 1155
 	"bip": "",
... ...
@@ -2890,3 +2890,33 @@ func (s *DockerDaemonSuite) TestDaemonBackcompatPre17Volumes(c *check.C) {
2890 2890
 		c.Assert(matched, checker.True, check.Commentf("did find match for %+v", m))
2891 2891
 	}
2892 2892
 }
2893
+
2894
+func (s *DockerDaemonSuite) TestDaemonWithUserlandProxyPath(c *check.C) {
2895
+	testRequires(c, SameHostDaemon, DaemonIsLinux)
2896
+
2897
+	dockerProxyPath, err := exec.LookPath("docker-proxy")
2898
+	c.Assert(err, checker.IsNil)
2899
+	tmpDir, err := ioutil.TempDir("", "test-docker-proxy")
2900
+	c.Assert(err, checker.IsNil)
2901
+
2902
+	newProxyPath := filepath.Join(tmpDir, "docker-proxy")
2903
+	cmd := exec.Command("cp", dockerProxyPath, newProxyPath)
2904
+	c.Assert(cmd.Run(), checker.IsNil)
2905
+
2906
+	// custom one
2907
+	c.Assert(s.d.StartWithBusybox("--userland-proxy-path", newProxyPath), checker.IsNil)
2908
+	out, err := s.d.Cmd("run", "-p", "5000:5000", "busybox:latest", "true")
2909
+	c.Assert(err, checker.IsNil, check.Commentf(out))
2910
+
2911
+	// try with the original one
2912
+	c.Assert(s.d.Restart("--userland-proxy-path", dockerProxyPath), checker.IsNil)
2913
+	out, err = s.d.Cmd("run", "-p", "5000:5000", "busybox:latest", "true")
2914
+	c.Assert(err, checker.IsNil, check.Commentf(out))
2915
+
2916
+	// not exist
2917
+	c.Assert(s.d.Restart("--userland-proxy-path", "/does/not/exist"), checker.IsNil)
2918
+	out, err = s.d.Cmd("run", "-p", "5000:5000", "busybox:latest", "true")
2919
+	c.Assert(err, checker.NotNil, check.Commentf(out))
2920
+	c.Assert(out, checker.Contains, "driver failed programming external connectivity on endpoint")
2921
+	c.Assert(out, checker.Contains, "/does/not/exist: no such file or directory")
2922
+}
... ...
@@ -64,6 +64,7 @@ dockerd - Enable daemon mode
64 64
 [**--tlskey**[=*~/.docker/key.pem*]]
65 65
 [**--tlsverify**]
66 66
 [**--userland-proxy**[=*true*]]
67
+[**--userland-proxy-path**[=*""*]]
67 68
 [**--userns-remap**[=*default*]]
68 69
 
69 70
 # DESCRIPTION
... ...
@@ -272,6 +273,9 @@ output otherwise.
272 272
 **--userland-proxy**=*true*|*false*
273 273
     Rely on a userland proxy implementation for inter-container and outside-to-container loopback communications. Default is true.
274 274
 
275
+**--userland-proxy-path**=""
276
+  Path to the userland proxy binary.
277
+
275 278
 **--userns-remap**=*default*|*uid:gid*|*user:group*|*user*|*uid*
276 279
     Enable user namespaces for containers on the daemon. Specifying "default" will cause a new user and group to be created to handle UID and GID range remapping for the user namespace mappings used for contained processes. Specifying a user (or uid) and optionally a group (or gid) will cause the daemon to lookup the user and group's subordinate ID ranges for use as the user namespace mappings for contained processes.
277 280