mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
rootless: optional support for lxc-user-nic SUID binary
lxc-user-nic can eliminate slirp overhead but needs /etc/lxc/lxc-usernet to be configured for the current user.
To use lxc-user-nic, $DOCKERD_ROOTLESS_ROOTLESSKIT_NET=lxc-user-nic also needs to be set.
This commit also bumps up RootlessKit from v0.3.0 to v0.4.0:
70e0502f32...e92d5e772e
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
parent
3cd54c28fd
commit
63a66b0eb0
3 changed files with 40 additions and 21 deletions
|
@ -9,7 +9,9 @@
|
||||||
# External dependencies:
|
# External dependencies:
|
||||||
# * newuidmap and newgidmap needs to be installed.
|
# * newuidmap and newgidmap needs to be installed.
|
||||||
# * /etc/subuid and /etc/subgid needs to be configured for the current user.
|
# * /etc/subuid and /etc/subgid needs to be configured for the current user.
|
||||||
# * Either slirp4netns (v0.3+) or VPNKit needs to be installed.
|
# * Either one of slirp4netns (v0.3+), VPNKit, lxc-user-nic needs to be installed.
|
||||||
|
# slirp4netns is used by default if installed. Otherwise fallsback to VPNKit.
|
||||||
|
# The default value can be overridden with $DOCKERD_ROOTLESS_ROOTLESSKIT_NET=(slirp4netns|vpnkit|lxc-user-nic)
|
||||||
#
|
#
|
||||||
# See the documentation for the further information.
|
# See the documentation for the further information.
|
||||||
|
|
||||||
|
@ -35,12 +37,17 @@ if [ -z $rootlesskit ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
net=""
|
: "${DOCKERD_ROOTLESS_ROOTLESSKIT_NET:=}"
|
||||||
mtu=""
|
: "${DOCKERD_ROOTLESS_ROOTLESSKIT_MTU:=}"
|
||||||
|
net=$DOCKERD_ROOTLESS_ROOTLESSKIT_NET
|
||||||
|
mtu=$DOCKERD_ROOTLESS_ROOTLESSKIT_MTU
|
||||||
|
if [ -z $net ]; then
|
||||||
if which slirp4netns >/dev/null 2>&1; then
|
if which slirp4netns >/dev/null 2>&1; then
|
||||||
if slirp4netns --help | grep -- --disable-host-loopback; then
|
if slirp4netns --help | grep -- --disable-host-loopback; then
|
||||||
net=slirp4netns
|
net=slirp4netns
|
||||||
|
if [ -z $mtu ]; then
|
||||||
mtu=65520
|
mtu=65520
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "slirp4netns does not support --disable-host-loopback. Falling back to VPNKit."
|
echo "slirp4netns does not support --disable-host-loopback. Falling back to VPNKit."
|
||||||
fi
|
fi
|
||||||
|
@ -48,12 +55,15 @@ fi
|
||||||
if [ -z $net ]; then
|
if [ -z $net ]; then
|
||||||
if which vpnkit >/dev/null 2>&1; then
|
if which vpnkit >/dev/null 2>&1; then
|
||||||
net=vpnkit
|
net=vpnkit
|
||||||
mtu=1500
|
|
||||||
else
|
else
|
||||||
echo "Either slirp4netns (v0.3+) or vpnkit needs to be installed"
|
echo "Either slirp4netns (v0.3+) or vpnkit needs to be installed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
if [ -z $mtu ]; then
|
||||||
|
mtu=1500
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z $_DOCKERD_ROOTLESS_CHILD ]; then
|
if [ -z $_DOCKERD_ROOTLESS_CHILD ]; then
|
||||||
_DOCKERD_ROOTLESS_CHILD=1
|
_DOCKERD_ROOTLESS_CHILD=1
|
||||||
|
@ -66,7 +76,8 @@ if [ -z $_DOCKERD_ROOTLESS_CHILD ]; then
|
||||||
# (by either systemd-networkd or NetworkManager)
|
# (by either systemd-networkd or NetworkManager)
|
||||||
# * /run: copy-up is required so that we can create /run/docker (hardcoded for plugins) in our namespace
|
# * /run: copy-up is required so that we can create /run/docker (hardcoded for plugins) in our namespace
|
||||||
$rootlesskit \
|
$rootlesskit \
|
||||||
--net=$net --mtu=$mtu --disable-host-loopback --port-driver=builtin \
|
--net=$net --mtu=$mtu \
|
||||||
|
--disable-host-loopback --port-driver=builtin \
|
||||||
--copy-up=/etc --copy-up=/run \
|
--copy-up=/etc --copy-up=/run \
|
||||||
$DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS \
|
$DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS \
|
||||||
$0 $@
|
$0 $@
|
||||||
|
|
|
@ -20,7 +20,6 @@ $ grep ^$(whoami): /etc/subgid
|
||||||
penguin:231072:65536
|
penguin:231072:65536
|
||||||
```
|
```
|
||||||
|
|
||||||
* Either [slirp4netns](https://github.com/rootless-containers/slirp4netns) (v0.3+) or [VPNKit](https://github.com/moby/vpnkit) needs to be installed. slirp4netns is preferred for the best performance.
|
|
||||||
|
|
||||||
### Distribution-specific hint
|
### Distribution-specific hint
|
||||||
|
|
||||||
|
@ -82,3 +81,12 @@ To route ping packets, you need to set up `net.ipv4.ping_group_range` properly a
|
||||||
```console
|
```console
|
||||||
$ sudo sh -c "echo 0 2147483647 > /proc/sys/net/ipv4/ping_group_range"
|
$ sudo sh -c "echo 0 2147483647 > /proc/sys/net/ipv4/ping_group_range"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Changing network stack
|
||||||
|
|
||||||
|
`dockerd-rootless.sh` uses [slirp4netns](https://github.com/rootless-containers/slirp4netns) (if installed) or [VPNKit](https://github.com/moby/vpnkit) as the network stack by default.
|
||||||
|
These network stacks run in userspace and might have performance overhead. See [RootlessKit documentation](https://github.com/rootless-containers/rootlesskit/tree/v0.4.0#network-drivers) for further information.
|
||||||
|
|
||||||
|
Optionally, you can use `lxc-user-nic` instead for the best performance.
|
||||||
|
To use `lxc-user-nic`, you need to edit [`/etc/lxc/lxc-usernet`](https://github.com/rootless-containers/rootlesskit/tree/v0.4.0#--netlxc-user-nic-experimental) and set `$DOCKERD_ROOTLESS_ROOTLESSKIT_NET=lxc-user-nic`.
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# v0.3.0
|
# v0.4.0
|
||||||
ROOTLESSKIT_COMMIT=70e0502f328bc5ffb14692a7ea41abb77196043b
|
ROOTLESSKIT_COMMIT=e92d5e772ee7e103aecf380c5874a40c52876ff0
|
||||||
|
|
||||||
install_rootlesskit() {
|
install_rootlesskit() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|
Loading…
Reference in a new issue