reorganization-edit docs for WP

This commit is contained in:
Anita Buehrle committed 2016-03-02 13:54:05 -06:00
1 parent 532a6b69d9
commit bdc9eae000
59 files changed
+3184 -2148

No files matched your search

@@ -0,0 +1,60 @@
---
title: Using Automatic Discovery With the Weave Proxy
layout: default
---
Containers launched via the proxy use [weavedns](/site/weavedns/overview-using-weavedns.md)
automatically if it is running when they are started -
see the [weavedns usage](/site/weavedns/overview-using-weavedns.md#usage) section for an in depth
explanation of the behaviour and how to control it.
Typically, the proxy passes on container names as-is to weavedns
for registration. However, there are situations in which the final container
name may be out of your control (for example, if you are using Docker orchestrators which
append control/namespacing identifiers to the original container names).
For those situations, the proxy provides the following flags:
* `--hostname-from-label<labelkey>`
* `--hostname-match <regexp>`
* `--hostname-replacement <replacement>`
When launching a container, the hostname is initialized to the
value of the container label using key `<labelkey>`. If no `<labelkey>` was
provided, then the container name is used.
Additionally, the hostname is matched against a regular expression `<regexp>` and based on that match,
`<replacement>` is used to obtain the final hostname, and then handed over to weaveDNS for registration.
For example, you can launch the proxy using all three flags, as follows:
host1$ weave launch-router && weave launch-proxy --hostname-from-label hostname-label --hostname-match '^aws-[0-9]+-(.*)$' --hostname-replacement 'my-app-$1'
host1$ eval $(weave env)
>>**Note:** regexp substitution groups must be pre-pended with a dollar sign
(for example, `$1`). For further details on the regular expression syntax see
[Google's re2 documentation](https://github.com/google/re2/wiki/Syntax).
After launching the Weave proxy with these flags, running a container named `aws-12798186823-foo` without labels results in
weavedns registering the hostname `my-app-foo` and not `aws-12798186823-foo`.
host1$ docker run -ti --name=aws-12798186823-foo ubuntu ping my-app-foo
PING my-app-foo.weave.local (10.32.0.2) 56(84) bytes of data.
64 bytes from my-app-foo.weave.local (10.32.0.2): icmp_seq=1 ttl=64 time=0.027 ms
64 bytes from my-app-foo.weave.local (10.32.0.2): icmp_seq=2 ttl=64 time=0.067 ms
Also, running a container named `foo` with the label
`hostname-label=aws-12798186823-foo` leads to the same hostname registration.
host1$ docker run -ti --name=foo --label=hostname-label=aws-12798186823-foo ubuntu ping my-app-foo
PING my-app-foo.weave.local (10.32.0.2) 56(84) bytes of data.
64 bytes from my-app-foo.weave.local (10.32.0.2): icmp_seq=1 ttl=64 time=0.031 ms
64 bytes from my-app-foo.weave.local (10.32.0.2): icmp_seq=2 ttl=64 time=0.042 ms
This is because, as explained above, if providing `--hostname-from-label`
to the proxy, the specified label takes precedence over the container's name.
**See Also**
* [Name resolution via `/etc/hosts`](/site/weave-docker-api/name-resolution-proxy.md)
* [How Weave Finds Containers](/site/weavedns/how-works-weavedns.md)
+42
View File
@@ -0,0 +1,42 @@
---
title: Automatic IP Allocation and the Weave Proxy
layout: default
---
If [automatic IP address allocation](/site/ipam/overview-init-ipam.md) is enabled in Weave (by default IPAM is enabled),
then containers started via the proxy are automatically assigned an IP address, *without having to specify any
special environment variables or any other options*.
host1$ docker run -ti ubuntu
To use a specific subnet, we pass a `WEAVE_CIDR` to the container, e.g.
host1$ docker run -ti -e WEAVE_CIDR=net:10.32.2.0/24 ubuntu
To start a container without connecting it to the Weave network, pass
`WEAVE_CIDR=none`, for example:
host1$ docker run -ti -e WEAVE_CIDR=none ubuntu
###Disabling Automatic IP Address Allocation
If you do not want an IP to be assigned by default, the proxy needs to
be passed the `--no-default-ipalloc` flag, for example:
host1$ weave launch-proxy --no-default-ipalloc
In this configuration, containers with no `WEAVE_CIDR` environment
variable are not 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, start the
container with a blank `WEAVE_CIDR`, for example:
host1$ docker run -ti -e WEAVE_CIDR="" ubuntu
**See Also**
* [Address Allocation with IP Address Management (IPAM)](/site/ipam/overview-init-ipam.md)
* [How to Manually Specify IP Addresses and Subnets](/site/using-weave/manual-ip-address.md)
@@ -0,0 +1,46 @@
---
title: Launching Containers With Weave Run (without the Proxy)
layout: default
---
If you don't want to use the proxy, you can also launch
containers on to the Weave network using `weave run`:
$ weave run -ti ubuntu
The arguments after `run` are passed through to `docker run`. Therefore you
can freely specify whatever Docker options you need.
Once the container is started, `weave run` attaches it to the Weave network, and in
this example, it obtains an automatically allocated IP.
You can specify IP addresses manually instead:
$ weave run 10.2.1.1/24 -ti ubuntu
`weave run` rewrites `/etc/hosts` in the same way
[the proxy does](/site/weave-docker-api/name-resolution-proxy.md). If you need to keep
the original file, specify `--no-rewrite-hosts` when running
the container:
$ weave run --no-rewrite-hosts 10.2.1.1/24 -ti ubuntu
There are some limitations to starting containers using `weave run`:
* containers are always started in the background, i.e. the equivalent
of always supplying the -d option to docker run
* the --rm option to docker run, for automatically removing containers
after they stop, is not available
* the Weave network interface may not be available immediately on
container startup.
Finally, there is a `weave start` command which starts existing
containers using `docker start` and attaches them to the Weave network.
**See Also**
* [Setting Up The Weave Docker API Proxy](/site/weave-docker-api/set-up-proxy.md)
* [Securing Docker Communications With TLS](/site/weave-docker-api/securing-proxy.md)
* [Name Resolution via `/etc/hosts`](/site/weave-docker-api/name-resolution-proxy.md)
@@ -0,0 +1,34 @@
---
title: Name resolution via `/etc/hosts`
layout: default
---
When starting Weave-enabled containers, the proxy automatically
replaces the container's `/etc/hosts` file, and disables Docker's control
over it. The new file contains an entry for the container's hostname
and Weave IP address, as well as additional entries that have been
specified using the `--add-host` parameters.
This ensures that:
- name resolution of the container's hostname, for example, via `hostname -i`,
returns the Weave IP address. This is required for many cluster-aware
applications to work.
- unqualified names get resolved via DNS, for example typically via weavedns
to Weave IP addresses. This is required so that in a typical setup
one can simply "ping <container-name>", i.e. without having to
specify a `.weave.local` suffix.
If you prefer to keep `/etc/hosts` under Docker's control (for
example, because you need the hostname to resolve to the Docker-assigned
IP instead of the Weave IP, or you require name resolution for
Docker-managed networks), the proxy must be launched using the
`--no-rewrite-hosts` flag.
host1$ weave launch-router && weave launch-proxy --no-rewrite-hosts
**See Also**
* [Using Automatic Discovery With the Weave Proxy](/site/weave-docker-api/automatic-discovery-proxy.md)
+60
View File
@@ -0,0 +1,60 @@
---
title: Securing the Docker Communications With TLS
layout: default
---
If you are [connecting to the docker daemon with
TLS](https://docs.docker.com/articles/https/), you most likely want
to do the same when connecting to the proxy. The proxy
automatically detects the Docker daemon's TLS configuration, and
attempts to duplicate it.
In the standard auto-detection case you can launch a TLS-enabled proxy as follows:
host1$ weave launch-proxy
To disable auto-detection of TLS configuration, you can either pass
the `--no-detect-tls` flag, or you can manually configure the proxy's TLS using
the same TLS-related command-line flags supplied to the Docker
daemon.
For example, if you generated your certificates and keys
into the Docker host's `/tls` directory, launch the proxy using:
host1$ weave launch-proxy --tlsverify --tlscacert=/tls/ca.pem \
--tlscert=/tls/server-cert.pem --tlskey=/tls/server-key.pem
The paths to your certificates and key must be provided as absolute
paths as they exist on the Docker host.
Because the proxy connects to the Docker daemon at
`unix:///var/run/docker.sock`, you must ensure that the daemon is actually
listening there. To do ensure this, pass the `-H unix:///var/run/docker.sock` option when starting the Docker daemon,
in addition to the `-H` options for configuring the TCP listener. See
[the Docker documentation](https://docs.docker.com/articles/basics/#bind-docker-to-another-host-port-or-a-unix-socket)
for an example.
With the proxy running over TLS, you can configure the Docker
client to use TLS on a per-invocation basis by running:
$ docker --tlsverify --tlscacert=ca.pem --tlscert=cert.pem \
--tlskey=key.pem -H=tcp://host1:12375 version
...
or, [by default](https://docs.docker.com/articles/https/#secure-by-default), using:
$ mkdir -pv ~/.docker
$ cp -v {ca,cert,key}.pem ~/.docker
$ eval $(weave env)
$ export DOCKER_TLS_VERIFY=1
$ docker version
...
This is exactly the same configuration used when connecting to the
Docker daemon directly, except that the specified port is the Weave
proxy port.
**See Also**
* [Setting Up The Weave Docker API Proxy](/site/weave-docker-api/set-up-proxy.md)
+78
View File
@@ -0,0 +1,78 @@
---
title: Setting Up The Weave Docker API Proxy
layout: default
---
The Docker API proxy automatically attaches containers to the Weave
network when they are started using the ordinary Docker
[command-line interface](https://docs.docker.com/reference/commandline/cli/)
or the [remote API](https://docs.docker.com/reference/api/docker_remote_api/),
instead of `weave run`.
###Setting Up The Weave Docker API Proxy
The proxy sits between the Docker client (command line or API) and the
Docker daemon, and intercepts the communication between the two. You can
start it simultaneously with the router and weavedns via `launch`:
host1$ weave launch
or independently via `launch-proxy`:
host1$ weave launch-router && weave launch-proxy
The first form is more convenient. But only `launch-proxy` can be passed configuration arguments.
Therefor if you need to modify the default behaviour of the proxy, you must use `launch-proxy`.
By default, the proxy decides where to listen based on how the
launching client connects to Docker. If the launching client connected
over a UNIX socket, the proxy listens on `/var/run/weave/weave.sock`. If
the launching client connects over TCP, the proxy listens on port
12375, on all network interfaces. This can be adjusted using the `-H`
argument, for example:
host1$ weave launch-proxy -H tcp://127.0.0.1:9999
If no TLS or listening interfaces are set, TLS is autoconfigured
based on the Docker daemon's settings, and the listening interfaces are
autoconfigured based on your Docker client's settings.
Multiple `-H` arguments can be specified. If you are working with a
remote docker daemon, then any firewalls inbetween need to be
configured to permit access to the proxy port.
All docker commands can be run via the proxy, so it is safe to adjust
your `DOCKER_HOST` to point at the proxy. Weave provides a convenient
command for this:
host1$ eval $(weave env)
host1$ docker ps
...
The prior settings can be restored with
host1$ eval $(weave env --restore)
Alternatively, the proxy host can be set on a per-command basis with
host1$ docker $(weave config) ps
The proxy can be stopped independently with
host1$ weave stop-proxy
or in conjunction with the router and weaveDNS via `stop`.
If you set your `DOCKER_HOST` to point at the proxy, you should revert
to the original settings prior to stopping the proxy.
**See Also**
* [Using The Weave Docker API Proxy](/site/weave-docker-api/using-proxy.md)
* [Securing Docker Communications With TLS](securing-proxy.md)
* [Launching Containers With Weave Run (without the Proxy)](/site/weave-docker-api/launching-without-proxy.md)
@@ -0,0 +1,25 @@
---
title: Troubleshooting
layout: default
---
The command
weave status
reports on the current status of various weave components, including
the proxy, if it is running:
````
...
weave proxy is running
````
Information on the operation of the proxy can be obtained from the
weaveproxy container logs using:
docker logs weaveproxy
**See Also**
* [Troubleshooting Weave](/site/troubleshooting.md)
+62
View File
@@ -0,0 +1,62 @@
---
title: Using The Weave Docker API Proxy
layout: default
---
When containers are created via the Weave proxy, their entrypoint is
modified to wait for the Weave network interface to become
available.
When they are started via the Weave proxy, containers are
[automatically assigned IP addresses](/site/ipam/overview-init-ipam.md) and connected to the
Weave network.
###Creating and Starting Containers with the Weave Proxy
To create and start a container via the Weave proxy run:
host1$ docker run -ti ubuntu
or, equivalently run:
host1$ docker create -ti ubuntu
5ef831df61d50a1a49272357155a976595e7268e590f0a2c75693337b14e1382
host1$ docker start 5ef831df61d50a1a49272357155a976595e7268e590f0a2c75693337b14e1382
Specific IP addresses and networks can be supplied in the `WEAVE_CIDR`
environment variable, for example:
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"`.
###Returning Weave Network Settings Instead of Docker Network Settings
The Docker NetworkSettings (including IP address, MacAddress, and
IPPrefixLen), are still returned when `docker inspect` is run. If you want
`docker inspect` to return the Weave NetworkSettings instead, then the
proxy must be launched using the `--rewrite-inspect` flag.
This command substitutes the Weave Network settings when the container has a
Weave IP. If a container has more than one Weave IP, then the inspect call
only includes one of them.
host1$ weave launch-router && weave launch-proxy --rewrite-inspect
###Multicast Traffic and Launching the Weave Proxy
By default, multicast traffic is routed over the Weave network.
To turn this off, e.g. because you want to configure your own multicast
route, add the `--no-multicast-route` flag to `weave launch-proxy`.
**See Also**
* [Setting Up The Weave Docker API Proxy](/site/weave-docker-api/set-up-proxy.md)
* [Securing Docker Communications With TLS](securing-proxy.md)
* [Launching Containers With Weave Run (without the Proxy)](/site/weave-docker-api/launching-without-proxy.md)