toolbox: Use env var for share-system arg

Since systemd v239, using environment variable $SYSTEMD_NSPAWN_SHARE_*
instead of --share-system argument has been preferred. This change
modifies the systemd-nspawn command to respect this. In practice, this
will remove the warning message that is printed when using toolbox and
satisfy the systemd-nspawn spec.

BUG=b/136605701
TEST=manual verification
RELEASE_NOTE=none

Change-Id: I025046e57bf0fabe68c384b771a61e94a1ceaf06
1 file changed
tree: 81305e765b2d2e57731f71aeacfd76ca25c68958
  1. CONTRIBUTING.md
  2. DCO
  3. LICENSE
  4. NOTICE
  5. README.md
  6. toolbox
README.md

toolbox - bring your tools with you

toolbox is a small script that launches a container to let you bring in your favorite debugging or admin tools.

Usage

$ /usr/bin/toolbox
Spawning container core-fedora-latest on /var/lib/toolbox/core-fedora-latest.
Press ^] three times within 1s to kill container.
-bash-4.3# yum install tcpdump
...
-bash-4.3# tcpdump -i ens3
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens3, link-type EN10MB (Ethernet), capture size 65535 bytes

Advanced Usage

Use a custom image

toolbox uses a Fedora-based userspace environment by default, but this can be changed to any Docker image. Simply override environment variables in $HOME/.toolboxrc:

core@core-01 ~ $ cat ~/.toolboxrc
TOOLBOX_DOCKER_IMAGE=ubuntu-debootstrap
TOOLBOX_DOCKER_TAG=14.04
core@core-01 ~ $ toolbox
Spawning container core-ubuntu-debootstrap-14.04 on /var/lib/toolbox/core-ubuntu-debootstrap-14.04.
Press ^] three times within 1s to kill container.
root@core-01:~# apt-get update && apt-get install tcpdump

Automatically enter toolbox on login

Set an /etc/passwd entry for one of the users to /usr/bin/toolbox:

useradd bob -m -p '*' -s /usr/bin/toolbox -U -G sudo,docker

Now when SSHing into the system as that user, toolbox will automatically be started:

$ ssh bob@hostname.example.com
CoreOS alpha (633.1.0)
...
Spawning container core-fedora-latest on /var/lib/toolbox/core-fedora-latest.
-bash-4.3 # yum install emacs
-bash-4.3 # emacs /media/root/etc/systemd/system/docker.service

Bugs

Please use the CoreOS issue tracker to report all bugs, issues, and feature requests.