diff --git a/prog/weaveproxy/main.go b/prog/weaveproxy/main.go
index 8f66e59f..c896d872 100644
--- a/prog/weaveproxy/main.go
+++ b/prog/weaveproxy/main.go
@@ -31,6 +31,7 @@ func main() {
getopt.BoolVarLong(&justVersion, "version", 0, "print version and exit")
getopt.StringVar(&c.ListenAddr, 'H', fmt.Sprintf("address on which to listen (default %s)", defaultListenAddr))
getopt.StringVar(&c.DockerAddr, 'D', fmt.Sprintf("docker daemon URL to proxy (default %s)", defaultDockerAddr))
+ getopt.BoolVarLong(&c.NoDefaultIPAM, "no-default-ipam", 0, "do not automatically allocate addresses for containers without a WEAVE_CIDR")
getopt.StringVarLong(&c.TLSConfig.CACert, "tlscacert", 0, "Trust certs signed only by this CA")
getopt.StringVarLong(&c.TLSConfig.Cert, "tlscert", 0, "Path to TLS certificate file")
getopt.BoolVarLong(&c.TLSConfig.Enabled, "tls", 0, "Use TLS; implied by --tlsverify")
@@ -38,7 +39,6 @@ func main() {
getopt.BoolVarLong(&c.TLSConfig.Verify, "tlsverify", 0, "Use TLS and verify the remote")
getopt.BoolVarLong(&c.WithDNS, "with-dns", 'w', "instruct created containers to always use weaveDNS as their nameserver")
getopt.BoolVarLong(&c.WithoutDNS, "without-dns", 0, "instruct created containers to never use weaveDNS as their nameserver")
- getopt.BoolVarLong(&c.WithIPAM, "with-ipam", 'i', "automatically allocate addresses for containers without a WEAVE_CIDR")
getopt.Parse()
if justVersion {
diff --git a/proxy/create_container_interceptor.go b/proxy/create_container_interceptor.go
index 79ab1ad2..fa527d70 100644
--- a/proxy/create_container_interceptor.go
+++ b/proxy/create_container_interceptor.go
@@ -33,7 +33,7 @@ func (i *createContainerInterceptor) InterceptRequest(r *http.Request) error {
return err
}
- if cidrs, ok := weaveCIDRsFromConfig(container.Config); ok || i.proxy.WithIPAM {
+ if cidrs, ok := weaveCIDRsFromConfig(container.Config); ok || !i.proxy.NoDefaultIPAM {
Info.Printf("Creating container with WEAVE_CIDR \"%s\"", strings.Join(cidrs, " "))
if container.HostConfig == nil {
container.HostConfig = &docker.HostConfig{}
diff --git a/proxy/create_exec_interceptor.go b/proxy/create_exec_interceptor.go
index a420c4d6..a2f3b4bb 100644
--- a/proxy/create_exec_interceptor.go
+++ b/proxy/create_exec_interceptor.go
@@ -29,7 +29,7 @@ func (i *createExecInterceptor) InterceptRequest(r *http.Request) error {
return err
}
- if cidrs, ok := weaveCIDRsFromConfig(container.Config); ok || i.proxy.WithIPAM {
+ if cidrs, ok := weaveCIDRsFromConfig(container.Config); ok || !i.proxy.NoDefaultIPAM {
Info.Printf("Exec in container %s with WEAVE_CIDR \"%s\"", container.ID, strings.Join(cidrs, " "))
cmd := append(weaveWaitEntrypoint, "-s")
options.Cmd = append(cmd, options.Cmd...)
diff --git a/proxy/proxy.go b/proxy/proxy.go
index 1c44b679..b1e8a24f 100644
--- a/proxy/proxy.go
+++ b/proxy/proxy.go
@@ -32,13 +32,13 @@ type Proxy struct {
}
type Config struct {
- DockerAddr string
- ListenAddr string
- TLSConfig TLSConfig
- Version string
- WithDNS bool
- WithoutDNS bool
- WithIPAM bool
+ DockerAddr string
+ ListenAddr string
+ NoDefaultIPAM bool
+ TLSConfig TLSConfig
+ Version string
+ WithDNS bool
+ WithoutDNS bool
}
func NewProxy(c Config) (*Proxy, error) {
diff --git a/proxy/start_container_interceptor.go b/proxy/start_container_interceptor.go
index 774e3104..9b22850d 100644
--- a/proxy/start_container_interceptor.go
+++ b/proxy/start_container_interceptor.go
@@ -22,7 +22,7 @@ func (i *startContainerInterceptor) InterceptResponse(r *http.Response) error {
}
cidrs, ok := weaveCIDRsFromConfig(container.Config)
- if !ok && !i.proxy.WithIPAM {
+ if !ok && i.proxy.NoDefaultIPAM {
Debug.Print("No Weave CIDR, ignoring")
return nil
}
diff --git a/site/proxy.md b/site/proxy.md
index f96c2fdd..f171352d 100644
--- a/site/proxy.md
+++ b/site/proxy.md
@@ -68,19 +68,24 @@ revert to the original setting.
When containers are created via the weave proxy, their entrypoint will
be modified to wait for the weave network interface to become
-available. When they are started via the weave proxy, any IP addresses
-and networks specified in the `WEAVE_CIDR` environment variable will
-be attached. We can create and start a container via the weave proxy
+available. When they are started via the weave proxy, containers will
+be [automatically assigned IP addresses](#ipam) and connected to the
+weave network. We can create and start a container via the weave proxy
with
- host1$ docker run -e WEAVE_CIDR=10.2.1.1/24 -ti ubuntu
+ host1$ docker run -ti ubuntu
or, equivalently with
- host1$ docker create -e WEAVE_CIDR=10.2.1.1/24 -ti ubuntu
+ host1$ docker create -ti ubuntu
5ef831df61d50a1a49272357155a976595e7268e590f0a2c75693337b14e1382
host1$ docker start 5ef831df61d50a1a49272357155a976595e7268e590f0a2c75693337b14e1382
+Specific IP addresses and networks can be supplied in the `WEAVE_CIDR`
+environment variable, e.g.
+
+ host1$ docker run -e WEAVE_CIDR=10.2.1.1/24 -ti ubuntu
+
Multiple IP addresses and networks can be supplied in the `WEAVE_CIDR`
variable by space-separating them, as in
`WEAVE_CIDR="10.2.1.1/24 10.2.2.1/24"`.
@@ -94,27 +99,28 @@ can be started in foreground mode, and can be automatically removed
## Automatic IP address assignment
If [automatic IP address assignment](ipam.html) is enabled in weave,
-which it is by default, then containers started via the proxy can be
-automatically assigned an IP address by providing a blank `WEAVE_CIDR`
-environment variable, as in
-
- host1$ docker run -e WEAVE_CIDR= -ti ubuntu
-
-Furthermore, it is possible to configure the proxy such that all
-containers started via it are automatically assigned an IP address and
-attached to weave network, *without having to specify any special
-environment variables or other options*. To do this we launch the
-proxy with the `--with-ipam` option, e.g.
-
- host1$ weave launch-proxy --with-ipam
-
-Now any container started via the proxy, e.g. with
+which it is by default, then containers started via the proxy will be
+automatically assigned an IP address, *without having to specify any
+special environment variables or other options*.
host1$ docker run -ti ubuntu
-gets attached to the weave network with an automatically assigned IP
-address. Containers started with a `WEAVE_CIDR` environment variable
-are handled as before.
+To use a specific IP, we pass a `WEAVE_CIDR` to the container, e.g.
+
+ host1$ docker run -ti -e WEAVE_CIDR=10.2.1.1/24 ubuntu
+
+To start containers without connecting them to the weave network, the
+proxy needs to be passed the `--no-default-ipam` flag, e.g.
+
+ host1$ docker launch-proxy --no-default-ipam
+
+In this configuration, containers with no `WEAVE_CIDR` environment
+variable will not be connected to the weave network. Containers
+started with a `WEAVE_CIDR` environment variable are handled as
+before. To automatically assign an address in this mode, we start the
+container with a blank `WEAVE_CIDR`, e.g.
+
+ host1$ docker run -ti -e WEAVE_CIDR= ubuntu
## Automatic discovery
@@ -143,12 +149,12 @@ to point at the latter:
host1$ weave launch
host1$ weave launch-dns
- host1$ weave launch-proxy --with-ipam
+ host1$ weave launch-proxy
host1$ eval "$(weave proxy-env)"
host2$ weave launch host1
host2$ weave launch-dns
- host2$ weave launch-proxy --with-ipam
+ host2$ weave launch-proxy
host2$ eval "$(weave proxy-env)"
Now let us start a named container on one host, and ping it, by name,
diff --git a/test/600_proxy_docker_py_test.sh b/test/600_proxy_docker_py_test.sh
index dc5e3282..b61de7a8 100755
--- a/test/600_proxy_docker_py_test.sh
+++ b/test/600_proxy_docker_py_test.sh
@@ -4,7 +4,7 @@
start_suite "Run docker-py test suite against the proxy"
-weave_on $HOST1 launch-proxy
+weave_on $HOST1 launch-proxy --no-default-ipam
assert_raises "docker_on $HOST1 ps | grep weaveproxy"
assert_raises "docker_on $HOST1 run \
-e NOT_ON_HOST=true \
diff --git a/test/620_proxy_entrypoint_command_test.sh b/test/620_proxy_entrypoint_command_test.sh
index 14a6a8ca..f2b5f959 100755
--- a/test/620_proxy_entrypoint_command_test.sh
+++ b/test/620_proxy_entrypoint_command_test.sh
@@ -28,7 +28,7 @@ run_container "--entrypoint='grep' false ^1$ /sys/class/net/ethwe/carrier"
weave_on $HOST1 launch -iprange 10.2.2.0/24
docker_on $HOST1 kill weaveproxy
-weave_on $HOST1 launch-proxy --with-ipam
+weave_on $HOST1 launch-proxy
assert_raises "proxy docker_on $HOST1 run check-ethwe-up"
diff --git a/test/660_proxy_ipam_test.sh b/test/660_proxy_ipam_test.sh
index a0b04485..33d69999 100755
--- a/test/660_proxy_ipam_test.sh
+++ b/test/660_proxy_ipam_test.sh
@@ -9,14 +9,18 @@ start_suite "Ping proxied containers over cross-host weave network (with IPAM)"
weave_on $HOST1 launch -iprange $UNIVERSE
weave_on $HOST1 launch-proxy
weave_on $HOST2 launch -iprange $UNIVERSE $HOST1
-weave_on $HOST2 launch-proxy --with-ipam
+weave_on $HOST2 launch-proxy --no-default-ipam
-proxy docker_on $HOST1 run -e WEAVE_CIDR= --name=c1 -dt $SMALL_IMAGE /bin/sh
-proxy docker_on $HOST2 run --name=c2 -dt $SMALL_IMAGE /bin/sh
+proxy docker_on $HOST1 run --name=auto -dt $SMALL_IMAGE /bin/sh
+proxy docker_on $HOST2 run -e WEAVE_CIDR= --name=explicit -dt $SMALL_IMAGE /bin/sh
+proxy docker_on $HOST2 run --name=none -dt $SMALL_IMAGE /bin/sh
-C1=$(container_ip $HOST1 c1)
-C2=$(container_ip $HOST2 c2)
-assert_raises "proxy exec_on $HOST1 c1 $PING $C2"
-assert_raises "proxy exec_on $HOST2 c2 $PING $C1"
+AUTO=$(container_ip $HOST1 auto)
+EXPLICIT=$(container_ip $HOST2 explicit)
+assert_raises "proxy exec_on $HOST1 auto $PING $EXPLICIT"
+assert_raises "proxy exec_on $HOST2 explicit $PING $AUTO"
+
+assert_raises "container_ip $HOST2 none" 1
+assert_raises "proxy exec_on $HOST2 none ip link show | grep -v ethwe"
end_suite
diff --git a/weave b/weave
index 09737054..28e0ea0f 100755
--- a/weave
+++ b/weave
@@ -30,7 +30,7 @@ usage() {
echo " [-iprange [-ipsubnet ]] ..."
echo "weave launch-dns []"
echo "weave launch-proxy [-D ] [-H ]"
- echo " [--with-dns | --without-dns] [--with-ipam]"
+ echo " [--with-dns | --without-dns] [--no-default-ipam]"
echo "weave connect [--replace] [ ...]"
echo "weave forget ..."
echo "weave run [--with-dns | --without-dns] [ ...] ..."