Merge pull request #2885 from weaveworks/issues/2353-remove-weave-run
Remove 'weave run', 'start' and 'restart'
This commit is contained in:
commit
d6a5eaec3f
19 files changed
+114
-242
No files matched your search
+1
-1
@@ -7,7 +7,7 @@ menu_order: 70
|
|||||||
Weave Net automatically assigns containers a unique IP address
|
Weave Net automatically assigns containers a unique IP address
|
||||||
across the network, and also releases that address when the container
|
across the network, and also releases that address when the container
|
||||||
exits. Unless you explicitly specify an address, this occurs for all
|
exits. Unless you explicitly specify an address, this occurs for all
|
||||||
invocations of the `run`, `start`,
|
invocations of the
|
||||||
`attach`, `detach`, `expose`, and `hide` commands. Weave Net can also assign
|
`attach`, `detach`, `expose`, and `hide` commands. Weave Net can also assign
|
||||||
addresses in multiple subnets.
|
addresses in multiple subnets.
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,22 @@ where,
|
|||||||
|
|
||||||
>Note If you are using the Weave Docker API proxy, it will have modified `DOCKER_HOST` to point to the proxy and therefore you will have to pass `-e WEAVE_CIDR=none` to start a container that _doesn't_ get automatically attached to the weave network for the purposes of this example.
|
>Note If you are using the Weave Docker API proxy, it will have modified `DOCKER_HOST` to point to the proxy and therefore you will have to pass `-e WEAVE_CIDR=none` to start a container that _doesn't_ get automatically attached to the weave network for the purposes of this example.
|
||||||
|
|
||||||
|
If `weave attach` sees the container has a hostname with a
|
||||||
|
domain-name, it will add those into WeaveDNS (unless you turn this off
|
||||||
|
with the `--without-dns` argument).
|
||||||
|
|
||||||
|
host1$ docker run -dti --name=c1 --hostname=c1.weave.local weaveworks/ubuntu
|
||||||
|
host1$ weave attach c1
|
||||||
|
10.32.0.1
|
||||||
|
host1$ weave dns-lookup c1
|
||||||
|
10.32.0.1
|
||||||
|
|
||||||
|
If you would like `/etc/hosts` to contain the Weave Net address (the
|
||||||
|
same way [the proxy does](/site/weave-docker-api/name-resolution-proxy.md)),
|
||||||
|
specify `--rewrite-hosts` when running `weave attach`:
|
||||||
|
|
||||||
|
host1$ weave attach --rewrite-hosts c1
|
||||||
|
|
||||||
### Dynamically Detaching Containers
|
### Dynamically Detaching Containers
|
||||||
|
|
||||||
A container can be detached from a subnet, by using the `weave detach` command:
|
A container can be detached from a subnet, by using the `weave detach` command:
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ menu_order: 50
|
|||||||
The Docker API proxy automatically attaches containers to the Weave
|
The Docker API proxy automatically attaches containers to the Weave
|
||||||
network when they are started using the ordinary Docker
|
network when they are started using the ordinary Docker
|
||||||
[command-line interface](https://docs.docker.com/reference/commandline/cli/)
|
[command-line interface](https://docs.docker.com/reference/commandline/cli/)
|
||||||
or the [remote API](https://docs.docker.com/reference/api/docker_remote_api/),
|
or the [remote API](https://docs.docker.com/reference/api/docker_remote_api/).
|
||||||
instead of `weave run`.
|
|
||||||
|
|
||||||
### <a name="attaching-containers"></a>Attaching Containers to a Weave Network
|
### <a name="attaching-containers"></a>Attaching Containers to a Weave Network
|
||||||
|
|
||||||
@@ -30,9 +29,9 @@ Note that if a Docker container is started with the --net flag, then the Weave D
|
|||||||
is automatically disabled and is not used to attach containers.
|
is automatically disabled and is not used to attach containers.
|
||||||
See [Integrating Docker via the Network Plugin](/site/plugin.md).
|
See [Integrating Docker via the Network Plugin](/site/plugin.md).
|
||||||
|
|
||||||
**3.** Containers can also be attached to the Weave network with `weave run` commands. This method also
|
**3.** Containers can also be attached to the Weave network with `weave attach` commands. This method also
|
||||||
does not use the Weave Docker API Proxy.
|
does not use the Weave Docker API Proxy.
|
||||||
See [Launching Containers With Weave Run (without the Proxy)](/site/weave-docker-api/launching-without-proxy.md).
|
See [Dynamically Attaching and Detaching Containers](/site/using-weave/dynamically-attach-containers.md).
|
||||||
|
|
||||||
### <a name="weave-api-proxy"></a>Setting Up The Weave Net Docker API Proxy
|
### <a name="weave-api-proxy"></a>Setting Up The Weave Net Docker API Proxy
|
||||||
|
|
||||||
|
|||||||
@@ -3,44 +3,18 @@ title: Launching Containers With Weave Run (without the Proxy)
|
|||||||
menu_order: 50
|
menu_order: 50
|
||||||
---
|
---
|
||||||
|
|
||||||
|
In prior versions of Weave Net, we supported a command `weave run`
|
||||||
|
which would run a container and attach it to the Weave Network.
|
||||||
|
|
||||||
If you don't want to use the proxy, you can also launch
|
This command always had limitations, and now we have Docker plugins
|
||||||
containers on to the Weave network using `weave run`:
|
and the Weave Net Docker API Proxy which do not have those
|
||||||
|
limitations, we have removed `weave run`.
|
||||||
|
|
||||||
$ weave run -ti weaveworks/ubuntu
|
If you have scripts using `weave run`, you can achieve exactly the
|
||||||
|
same effect by combining `docker run` and `weave attach`; see
|
||||||
|
[Dynamically Attaching and Detaching
|
||||||
|
Containers](/site/using-weave/dynamically-attach-containers.md) for
|
||||||
|
details.
|
||||||
|
|
||||||
The arguments after `run` are passed through to `docker run`. Therefore you
|
The `weave start` and `weave restart` commands have also been removed,
|
||||||
can freely specify whatever Docker options you need.
|
for the same reasons.
|
||||||
|
|
||||||
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 weaveworks/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 weaveworks/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.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)
|
|
||||||
@@ -64,4 +64,3 @@ route, add the `--no-multicast-route` flag to `weave launch-proxy`.
|
|||||||
|
|
||||||
* [Setting Up The Weave Docker API Proxy](/site/weave-docker-api.md)
|
* [Setting Up The Weave Docker API Proxy](/site/weave-docker-api.md)
|
||||||
* [Securing Docker Communications With TLS](/site/weave-docker-api/securing-proxy.md)
|
* [Securing Docker Communications With TLS](/site/weave-docker-api/securing-proxy.md)
|
||||||
* [Launching Containers With Weave Run (without the Proxy)](/site/weave-docker-api/launching-without-proxy.md)
|
|
||||||
+1
-1
@@ -39,7 +39,7 @@ the hostname is not in the weaveDNS domain, the container is *not*
|
|||||||
registered, but it will still use weaveDNS for resolution.
|
registered, but it will still use weaveDNS for resolution.
|
||||||
|
|
||||||
To disable an application container's use of weaveDNS, add the
|
To disable an application container's use of weaveDNS, add the
|
||||||
`--without-dns` option to `weave run` or `weave launch-proxy`. To
|
`--without-dns` option to `weave launch-proxy`. To
|
||||||
disable weaveDNS itself, launch weave with the `--no-dns` option.
|
disable weaveDNS itself, launch weave with the `--no-dns` option.
|
||||||
|
|
||||||
**See Also**
|
**See Also**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ menu_order: 10
|
|||||||
|
|
||||||
The weaveDNS service running on every host acts as the nameserver for
|
The weaveDNS service running on every host acts as the nameserver for
|
||||||
containers on that host. It learns about hostnames for local containers
|
containers on that host. It learns about hostnames for local containers
|
||||||
from the proxy and from the `weave run` command.
|
from the proxy and from the `weave attach` command.
|
||||||
|
|
||||||
If a hostname is in the `.weave.local` domain, then weaveDNS records the association of that
|
If a hostname is in the `.weave.local` domain, then weaveDNS records the association of that
|
||||||
name with the container's Weave Net IP address(es) in its in-memory
|
name with the container's Weave Net IP address(es) in its in-memory
|
||||||
@@ -37,7 +37,7 @@ In the event that weaveDNS is launched in this way, it's important that
|
|||||||
other calls to `weave` also specify the bridge device:
|
other calls to `weave` also specify the bridge device:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ sudo DOCKER_BRIDGE=someother weave run ...
|
$ sudo DOCKER_BRIDGE=someother weave attach ...
|
||||||
```
|
```
|
||||||
|
|
||||||
**See Also**
|
**See Also**
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ The following topics are discussed:
|
|||||||
## <a name="domain-search-path"></a>Configuring the domain search paths
|
## <a name="domain-search-path"></a>Configuring the domain search paths
|
||||||
|
|
||||||
If you don't supply a domain search path (with `--dns-search=`), Weave
|
If you don't supply a domain search path (with `--dns-search=`), Weave
|
||||||
Net (via the [proxy](/site/weave-docker-api.md) or via `weave run`)
|
Net (via the [proxy](/site/weave-docker-api.md) or via `weave attach`)
|
||||||
tells a container to look for "bare" hostnames, like `pingme`, in its
|
tells a container to look for "bare" hostnames, like `pingme`, in its
|
||||||
own domain (or in `weave.local` if it has no domain).
|
own domain (or in `weave.local` if it has no domain).
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,9 @@ start_container $HOST2 net:$SUBNET_2 --name=c6
|
|||||||
C6=$(container_ip $HOST2 c6)
|
C6=$(container_ip $HOST2 c6)
|
||||||
assert_raises "exec_on $HOST1 c5 $PING $C6"
|
assert_raises "exec_on $HOST1 c5 $PING $C6"
|
||||||
|
|
||||||
# check that restart retains the same IP, and reclaims it in IPAM
|
# check that restart+attach retains the same IP, and reclaims it in IPAM
|
||||||
weave_on $HOST2 restart c6
|
docker_on $HOST2 restart c6
|
||||||
|
weave_on $HOST2 attach net:$SUBNET_2 c6
|
||||||
assert_raises "exec_on $HOST1 c5 $PING $C6"
|
assert_raises "exec_on $HOST1 c5 $PING $C6"
|
||||||
# check that restart does not create any additional DNS entry
|
# check that restart does not create any additional DNS entry
|
||||||
assert "weave_on $HOST2 report -f \"{{len .DNS.Entries}}\"" "6"
|
assert "weave_on $HOST2 report -f \"{{len .DNS.Entries}}\"" "6"
|
||||||
|
|||||||
@@ -15,10 +15,12 @@ weave_local_on $HOST1 reset
|
|||||||
weave_local_on $HOST1 launch --ipalloc-range 10.2.5.0/24
|
weave_local_on $HOST1 launch --ipalloc-range 10.2.5.0/24
|
||||||
assert_raises "docker_on $HOST1 ps | grep weave"
|
assert_raises "docker_on $HOST1 ps | grep weave"
|
||||||
|
|
||||||
weave_local_on $HOST1 run 10.2.6.5/24 -ti --name=c1 $SMALL_IMAGE /bin/sh
|
docker_on $HOST1 run -dti --name=c1 $SMALL_IMAGE /bin/sh
|
||||||
|
weave_local_on $HOST1 attach 10.2.6.5/24 c1
|
||||||
wait_for_attached $HOST1 c1
|
wait_for_attached $HOST1 c1
|
||||||
|
|
||||||
weave_local_on $HOST1 run -ti --name=c2 $SMALL_IMAGE /bin/sh
|
docker_on $HOST1 run -dti --name=c2 $SMALL_IMAGE /bin/sh
|
||||||
|
weave_local_on $HOST1 attach c2
|
||||||
wait_for_attached $HOST1 c2
|
wait_for_attached $HOST1 c2
|
||||||
|
|
||||||
assert "weave_local_on $HOST1 ps | wc -l" 3
|
assert "weave_local_on $HOST1 ps | wc -l" 3
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ weave_on $HOST1 launch-router
|
|||||||
weave_on $HOST1 launch-proxy --no-multicast-route
|
weave_on $HOST1 launch-proxy --no-multicast-route
|
||||||
weave_on $HOST1 launch-plugin # plugin defaults to multicast off except for 'net=weave'
|
weave_on $HOST1 launch-plugin # plugin defaults to multicast off except for 'net=weave'
|
||||||
|
|
||||||
start_container $HOST1 --no-multicast-route --name c1
|
docker_on $HOST1 run --name c1 -dt $SMALL_IMAGE /bin/sh
|
||||||
|
weave_on $HOST1 attach --no-multicast-route c1
|
||||||
proxy_start_container $HOST1 --name c2
|
proxy_start_container $HOST1 --name c2
|
||||||
start_container_local_plugin $HOST1 --name=c3
|
start_container_local_plugin $HOST1 --name=c3
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,6 @@ assert "weave_on $HOST1 dns-args" ""
|
|||||||
|
|
||||||
C=$(start_container_with_dns $HOST1 $C1/24 --name=c1)
|
C=$(start_container_with_dns $HOST1 $C1/24 --name=c1)
|
||||||
|
|
||||||
# hostname is left untouched; equals short container id
|
|
||||||
assert "exec_on $HOST1 c1 hostname" $(echo $C | cut -c1-12)
|
|
||||||
|
|
||||||
# domainname is left empty
|
|
||||||
assert "exec_on $HOST1 c1 dnsdomainname" ""
|
|
||||||
|
|
||||||
# external name resolution works
|
# external name resolution works
|
||||||
assert_raises "exec_on $HOST1 c1 getent hosts www.weave.works"
|
assert_raises "exec_on $HOST1 c1 getent hosts www.weave.works"
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,4 @@ docker_on $HOST1 run $DOPTS -dt $SMALL_IMAGE /bin/sh
|
|||||||
weave_on $HOST1 attach $C2/24 c2
|
weave_on $HOST1 attach $C2/24 c2
|
||||||
check
|
check
|
||||||
|
|
||||||
docker_on $HOST1 create $DOPTS -t $SMALL_IMAGE /bin/sh
|
|
||||||
weave_on $HOST1 start $C2/24 c2
|
|
||||||
check
|
|
||||||
|
|
||||||
end_suite
|
end_suite
|
||||||
@@ -34,8 +34,4 @@ assert_expected_fqdn "$HOSTNAME" -h $HOSTNAME --name=$NAME
|
|||||||
assert_expected_fqdn "$HOSTNAME" --hostname=$HOSTNAME --name=$NAME
|
assert_expected_fqdn "$HOSTNAME" --hostname=$HOSTNAME --name=$NAME
|
||||||
assert_expected_fqdn "$HOSTNAME" --hostname $HOSTNAME --name=$NAME
|
assert_expected_fqdn "$HOSTNAME" --hostname $HOSTNAME --name=$NAME
|
||||||
|
|
||||||
# Ensure we can launch a container with a name that is too long for hostname derivation
|
|
||||||
SIXTY_FIVE_CHARS=01234567890123456789012345678901234567890123456789012345678901234
|
|
||||||
assert_raises "start_container $HOST1 --name=$SIXTY_FIVE_CHARS"
|
|
||||||
|
|
||||||
end_suite
|
end_suite
|
||||||
@@ -12,7 +12,8 @@ check_dns() {
|
|||||||
chk=$1
|
chk=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
container=$(weave_on $HOST1 run $@ $IP/24 -t --add-host=$STATIC:$STATIC_IP $DNS_IMAGE /bin/sh)
|
container=$(docker_on $HOST1 run $(dns_args $HOST1 "$@") -dt $DNS_IMAGE /bin/sh)
|
||||||
|
weave_on $HOST1 attach $IP/24 "$@" --rewrite-hosts --add-host=$STATIC:$STATIC_IP $container
|
||||||
$chk $HOST1 $container $TARGET
|
$chk $HOST1 $container $TARGET
|
||||||
assert_dns_record $HOST1 $container $STATIC $STATIC_IP
|
assert_dns_record $HOST1 $container $STATIC $STATIC_IP
|
||||||
rm_containers $HOST1 $container
|
rm_containers $HOST1 $container
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ assert_equal() {
|
|||||||
assert "echo $result" "$expected"
|
assert "echo $result" "$expected"
|
||||||
}
|
}
|
||||||
|
|
||||||
start_suite "Weave run/start/attach/detach/expose/hide with multiple cidr arguments"
|
start_suite "Weave attach/detach/expose/hide with multiple cidr arguments"
|
||||||
|
|
||||||
# also check that these commands understand all address flavours
|
# also check that these commands understand all address flavours
|
||||||
|
|
||||||
@@ -73,15 +73,8 @@ start_suite "Weave run/start/attach/detach/expose/hide with multiple cidr argume
|
|||||||
weave_on $HOST1 launch-router --ipalloc-range 10.2.3.0/24
|
weave_on $HOST1 launch-router --ipalloc-range 10.2.3.0/24
|
||||||
|
|
||||||
# Run container with three cidrs
|
# Run container with three cidrs
|
||||||
CID=$(start_container $HOST1 10.2.1.1/24 ip:10.2.2.1/24 net:10.2.3.0/24 --name=multicidr -h $NAME)
|
CID=$(docker_on $HOST1 run --name=multicidr -h $NAME -dt $SMALL_IMAGE /bin/sh)
|
||||||
assert_ips_and_dns $HOST1 $CID $NAME. 10.2.1.1/24 10.2.2.1/24 10.2.3.1/24
|
weave_on $HOST1 attach 10.2.1.1/24 ip:10.2.2.1/24 net:10.2.3.0/24 $CID
|
||||||
|
|
||||||
# Stop the container
|
|
||||||
docker_on $HOST1 stop -t 1 $CID
|
|
||||||
assert_ips_and_dns $HOST1 $CID $NAME.
|
|
||||||
|
|
||||||
# Restart with three IPs
|
|
||||||
weave_on $HOST1 start 10.2.1.1/24 ip:10.2.2.1/24 net:10.2.3.0/24 $CID
|
|
||||||
assert_ips_and_dns $HOST1 $CID $NAME. 10.2.1.1/24 10.2.2.1/24 10.2.3.1/24
|
assert_ips_and_dns $HOST1 $CID $NAME. 10.2.1.1/24 10.2.2.1/24 10.2.3.1/24
|
||||||
|
|
||||||
# Remove two of them
|
# Remove two of them
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
|
|
||||||
. "$(dirname "$0")/config.sh"
|
|
||||||
|
|
||||||
C1=10.2.1.13
|
|
||||||
|
|
||||||
start_suite "Start containers with 'weave run' via proxy"
|
|
||||||
|
|
||||||
weave_on $HOST1 launch
|
|
||||||
|
|
||||||
proxy start_container $HOST1 $C1/24 --name=c1
|
|
||||||
# check we get exactly one IP back, the one specified
|
|
||||||
assert "weave_on $HOST1 ps c1 | cut -d ' ' -f 3-" $C1/24
|
|
||||||
|
|
||||||
end_suite
|
|
||||||
+53
-6
@@ -46,6 +46,15 @@ DOCKER_PORT=2375
|
|||||||
|
|
||||||
CHECKPOINT_DISABLE=true
|
CHECKPOINT_DISABLE=true
|
||||||
|
|
||||||
|
# The regexp here is far from precise, but good enough. (taken from weave script)
|
||||||
|
IP_REGEXP="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
|
||||||
|
CIDR_REGEXP="(ip:|net:)?$IP_REGEXP/[0-9]{1,2}"
|
||||||
|
|
||||||
|
is_cidr() {
|
||||||
|
[ $1 = "net:default" ] && return
|
||||||
|
echo "$1" | grep -E "^$CIDR_REGEXP$" >/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
upload_executable() {
|
upload_executable() {
|
||||||
host=$1
|
host=$1
|
||||||
file=$2
|
file=$2
|
||||||
@@ -140,16 +149,54 @@ exec_on() {
|
|||||||
docker -H tcp://$host:$DOCKER_PORT exec $container "$@"
|
docker -H tcp://$host:$DOCKER_PORT exec $container "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Look through 'docker run' args and try to make the hostname match the name
|
||||||
|
dns_args() {
|
||||||
|
local host=$1 NAME_ARG="" HOSTNAME_SPECIFIED=""
|
||||||
|
shift
|
||||||
|
weave_on $host dns-args "$@"
|
||||||
|
while [ $# -gt 0 ] ; do
|
||||||
|
case "$1" in
|
||||||
|
--name)
|
||||||
|
NAME_ARG="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--name=*)
|
||||||
|
NAME_ARG="${1#*=}"
|
||||||
|
;;
|
||||||
|
-h|--hostname|--hostname=*)
|
||||||
|
HOSTNAME_SPECIFIED=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
if [ -n "$NAME_ARG" -a -z "$HOSTNAME_SPECIFIED" ] ; then
|
||||||
|
echo " --hostname=$NAME_ARG.weave.local"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
start_container_image() {
|
||||||
|
local image=$1 host=$2 cidr="" weave_dns_args="" container
|
||||||
|
shift 2
|
||||||
|
if [ "$1" = "--without-dns" ] ; then
|
||||||
|
shift
|
||||||
|
else
|
||||||
|
weave_dns_args=$(dns_args $host "$@")
|
||||||
|
fi
|
||||||
|
is_cidr $1 && { cidr=$1; shift; }
|
||||||
|
container=$(docker_on $host run $weave_dns_args $name_args "$@" -dt $image /bin/sh)
|
||||||
|
if ! weave_on $host attach $cidr $container >/dev/null ; then
|
||||||
|
docker_on $host rm -f $container
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
echo $container
|
||||||
|
}
|
||||||
|
|
||||||
start_container() {
|
start_container() {
|
||||||
host=$1
|
start_container_image $SMALL_IMAGE "$@"
|
||||||
shift 1
|
|
||||||
weave_on $host run "$@" -t $SMALL_IMAGE /bin/sh
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start_container_with_dns() {
|
start_container_with_dns() {
|
||||||
host=$1
|
start_container_image $DNS_IMAGE "$@"
|
||||||
shift 1
|
|
||||||
weave_on $host run "$@" -t $DNS_IMAGE /bin/sh
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start_container_local_plugin() {
|
start_container_local_plugin() {
|
||||||
|
|||||||
@@ -70,12 +70,9 @@ weave env [--restore]
|
|||||||
weave connect [--replace] [<peer> ...]
|
weave connect [--replace] [<peer> ...]
|
||||||
forget <peer> ...
|
forget <peer> ...
|
||||||
|
|
||||||
weave run [--without-dns] [--no-rewrite-hosts] [--no-multicast-route]
|
weave attach [--without-dns] [--rewrite-hosts] [--no-multicast-route]
|
||||||
[<addr> ...] <docker run args> ...
|
[<addr> ...] <container_id>
|
||||||
start [<addr> ...] <container_id>
|
|
||||||
attach [<addr> ...] <container_id>
|
|
||||||
detach [<addr> ...] <container_id>
|
detach [<addr> ...] <container_id>
|
||||||
restart <container_id>
|
|
||||||
|
|
||||||
weave expose [<addr> ...] [-h <fqdn>]
|
weave expose [<addr> ...] [-h <fqdn>]
|
||||||
hide [<addr> ...]
|
hide [<addr> ...]
|
||||||
@@ -223,33 +220,6 @@ collect_cidr_args() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
dns_arg_count() {
|
|
||||||
if [ "$1" = "--with-dns" -o "$1" = "--without-dns" ] ; then
|
|
||||||
echo 1
|
|
||||||
else
|
|
||||||
echo 0
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
extra_hosts_args() {
|
|
||||||
DNS_EXTRA_HOSTS=
|
|
||||||
DNS_EXTRA_HOSTS_ARGS=
|
|
||||||
while [ $# -gt 0 ] ; do
|
|
||||||
case "$1" in
|
|
||||||
--add-host)
|
|
||||||
DNS_EXTRA_HOSTS="$2 $DNS_EXTRA_HOSTS"
|
|
||||||
DNS_EXTRA_HOSTS_ARGS="--add-host=$2 $DNS_EXTRA_HOSTS_ARGS"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--add-host=*)
|
|
||||||
DNS_EXTRA_HOSTS="${1#*=} $DNS_EXTRA_HOSTS"
|
|
||||||
DNS_EXTRA_HOSTS_ARGS="--add-host=${1#*=} $DNS_EXTRA_HOSTS_ARGS"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
kill_container() {
|
kill_container() {
|
||||||
docker kill $1 >/dev/null 2>&1 || true
|
docker kill $1 >/dev/null 2>&1 || true
|
||||||
}
|
}
|
||||||
@@ -281,46 +251,6 @@ elif [ "$1" = "env" -a "$2" = "--restore" ] ; then
|
|||||||
echo "DOCKER_HOST=$ORIG_DOCKER_HOST"
|
echo "DOCKER_HOST=$ORIG_DOCKER_HOST"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
elif [ "$1" = "run" -a -z "$IS_LOCAL" ] ; then
|
|
||||||
# non-local "run" is a special case because we want to use docker
|
|
||||||
# directly, rather than the docker in $EXEC_IMAGE remotely. That's
|
|
||||||
# because we are passing arbitrary arguments on to docker run, and
|
|
||||||
# we can't rely on our baked-in docker to support those arguments.
|
|
||||||
shift 1
|
|
||||||
|
|
||||||
handle_help_arg "$1"
|
|
||||||
[ "$1" = "--without-dns" ] || DNS_ARGS=$(exec_remote dns-args "$@" || true)
|
|
||||||
shift $(dns_arg_count "$@")
|
|
||||||
|
|
||||||
REWRITE_HOSTS=1
|
|
||||||
NO_MULTICAST_ROUTE=
|
|
||||||
while [ $# -gt 0 ]; do
|
|
||||||
case "$1" in
|
|
||||||
--no-rewrite-hosts)
|
|
||||||
REWRITE_HOSTS=
|
|
||||||
;;
|
|
||||||
--no-multicast-route)
|
|
||||||
NO_MULTICAST_ROUTE=1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
[ -n "$REWRITE_HOSTS" ] && extra_hosts_args "$@" && DNS_EXTRA_HOSTS_ARGS="--rewrite-hosts $DNS_EXTRA_HOSTS_ARGS"
|
|
||||||
[ -n "$NO_MULTICAST_ROUTE" ] && ATTACH_ARGS="--no-multicast-route"
|
|
||||||
|
|
||||||
collect_cidr_args "$@"
|
|
||||||
shift $CIDR_ARG_COUNT
|
|
||||||
CONTAINER=$(docker $DOCKER_CLIENT_ARGS run -e WEAVE_CIDR=none $DNS_ARGS -d "$@")
|
|
||||||
if ! exec_remote attach $CIDR_ARGS $DNS_EXTRA_HOSTS_ARGS $ATTACH_ARGS $CONTAINER >/dev/null ; then
|
|
||||||
kill_container $CONTAINER
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo $CONTAINER
|
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$IS_LOCAL" ] ; then
|
if [ -z "$IS_LOCAL" ] ; then
|
||||||
@@ -822,15 +752,6 @@ destroy_bridge() {
|
|||||||
run_iptables -t nat -X WEAVE >/dev/null 2>&1 || true
|
run_iptables -t nat -X WEAVE >/dev/null 2>&1 || true
|
||||||
}
|
}
|
||||||
|
|
||||||
do_or_die() {
|
|
||||||
CONTAINER="$1"
|
|
||||||
shift 1
|
|
||||||
if ! "$@" ; then
|
|
||||||
kill_container $CONTAINER
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
add_iface_fastdp() {
|
add_iface_fastdp() {
|
||||||
util_op add-datapath-interface $DATAPATH $1
|
util_op add-datapath-interface $DATAPATH $1
|
||||||
}
|
}
|
||||||
@@ -1371,13 +1292,6 @@ ipam_cidrs() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
ipam_cidrs_or_die() {
|
|
||||||
if ! ipam_cidrs "$@" ; then
|
|
||||||
kill_container $2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
show_addrs() {
|
show_addrs() {
|
||||||
addrs=
|
addrs=
|
||||||
for cidr in "$@" ; do
|
for cidr in "$@" ; do
|
||||||
@@ -2078,34 +1992,10 @@ EOF
|
|||||||
call_weave GET /report -H 'Accept: application/json'
|
call_weave GET /report -H 'Accept: application/json'
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
run)
|
run|start|restart)
|
||||||
dns_args "$@"
|
echo "The 'weave $COMMAND' command has been removed as of Weave Net version 2.0" >&2
|
||||||
shift $(dns_arg_count "$@")
|
echo "Please see release notes for further information" >&2
|
||||||
REWRITE_HOSTS=1
|
exit 1
|
||||||
NO_MULTICAST_ROUTE=
|
|
||||||
while [ $# -gt 0 ]; do
|
|
||||||
case "$1" in
|
|
||||||
--no-rewrite-hosts)
|
|
||||||
REWRITE_HOSTS=
|
|
||||||
;;
|
|
||||||
--no-multicast-route)
|
|
||||||
NO_MULTICAST_ROUTE=1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
collect_cidr_args "$@"
|
|
||||||
shift $CIDR_ARG_COUNT
|
|
||||||
CONTAINER=$(docker run -e WEAVE_CIDR=none $DNS_ARGS -d "$@")
|
|
||||||
create_bridge
|
|
||||||
ipam_cidrs_or_die allocate $CONTAINER $CIDR_ARGS
|
|
||||||
[ -n "$REWRITE_HOSTS" ] && extra_hosts_args "$@" && rewrite_etc_hosts $DNS_EXTRA_HOSTS
|
|
||||||
do_or_die $CONTAINER attach $ALL_CIDRS
|
|
||||||
when_weave_running with_container_fqdn $CONTAINER put_dns_fqdn $ALL_CIDRS
|
|
||||||
echo $CONTAINER
|
|
||||||
;;
|
;;
|
||||||
dns-args)
|
dns-args)
|
||||||
dns_args "$@"
|
dns_args "$@"
|
||||||
@@ -2114,26 +2004,18 @@ EOF
|
|||||||
docker-bridge-ip)
|
docker-bridge-ip)
|
||||||
util_op bridge-ip $DOCKER_BRIDGE
|
util_op bridge-ip $DOCKER_BRIDGE
|
||||||
;;
|
;;
|
||||||
start)
|
|
||||||
collect_cidr_args "$@"
|
|
||||||
shift $CIDR_ARG_COUNT
|
|
||||||
[ $# -eq 1 ] || usage
|
|
||||||
RES=$(docker start $1)
|
|
||||||
CONTAINER=$(container_id $1)
|
|
||||||
create_bridge
|
|
||||||
ipam_cidrs_or_die allocate $CONTAINER $CIDR_ARGS
|
|
||||||
do_or_die $CONTAINER attach $ALL_CIDRS
|
|
||||||
when_weave_running with_container_fqdn $CONTAINER put_dns_fqdn $ALL_CIDRS
|
|
||||||
echo $RES
|
|
||||||
;;
|
|
||||||
attach)
|
attach)
|
||||||
DNS_EXTRA_HOSTS=
|
DNS_EXTRA_HOSTS=
|
||||||
REWRITE_HOSTS=
|
REWRITE_HOSTS=
|
||||||
NO_MULTICAST_ROUTE=
|
NO_MULTICAST_ROUTE=
|
||||||
collect_cidr_args "$@"
|
collect_cidr_args "$@"
|
||||||
shift $CIDR_ARG_COUNT
|
shift $CIDR_ARG_COUNT
|
||||||
|
WITHOUT_DNS=
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
--without-dns)
|
||||||
|
WITHOUT_DNS=1
|
||||||
|
;;
|
||||||
--rewrite-hosts)
|
--rewrite-hosts)
|
||||||
REWRITE_HOSTS=1
|
REWRITE_HOSTS=1
|
||||||
;;
|
;;
|
||||||
@@ -2159,7 +2041,7 @@ EOF
|
|||||||
ipam_cidrs allocate $CONTAINER $CIDR_ARGS
|
ipam_cidrs allocate $CONTAINER $CIDR_ARGS
|
||||||
[ -n "$REWRITE_HOSTS" ] && rewrite_etc_hosts $DNS_EXTRA_HOSTS
|
[ -n "$REWRITE_HOSTS" ] && rewrite_etc_hosts $DNS_EXTRA_HOSTS
|
||||||
attach $ALL_CIDRS >/dev/null
|
attach $ALL_CIDRS >/dev/null
|
||||||
when_weave_running with_container_fqdn $CONTAINER put_dns_fqdn $ALL_CIDRS
|
[ -n "$WITHOUT_DNS" ] || when_weave_running with_container_fqdn $CONTAINER put_dns_fqdn $ALL_CIDRS
|
||||||
show_addrs $ALL_CIDRS
|
show_addrs $ALL_CIDRS
|
||||||
;;
|
;;
|
||||||
detach)
|
detach)
|
||||||
@@ -2175,20 +2057,6 @@ EOF
|
|||||||
done
|
done
|
||||||
show_addrs $ALL_CIDRS
|
show_addrs $ALL_CIDRS
|
||||||
;;
|
;;
|
||||||
restart)
|
|
||||||
[ $# -ge 1 ] || usage
|
|
||||||
create_bridge
|
|
||||||
ALL_CIDRS=$(with_container_addresses echo_cidrs $1)
|
|
||||||
RES=$(docker restart $1)
|
|
||||||
CONTAINER=$(container_id $1)
|
|
||||||
for CIDR in $ALL_CIDRS ; do
|
|
||||||
call_weave PUT /ip/$CONTAINER/$CIDR?check-alive=true
|
|
||||||
done
|
|
||||||
detect_awsvpc
|
|
||||||
do_or_die $CONTAINER attach $ALL_CIDRS
|
|
||||||
when_weave_running with_container_fqdn $CONTAINER put_dns_fqdn $ALL_CIDRS
|
|
||||||
echo $RES
|
|
||||||
;;
|
|
||||||
dns-add)
|
dns-add)
|
||||||
collect_dns_add_remove_args "$@"
|
collect_dns_add_remove_args "$@"
|
||||||
FN=put_dns_fqdn
|
FN=put_dns_fqdn
|
||||||
|
|||||||
Reference in new issue
Block a user