Update the logic for creating the container name for toolbox.

Starting from COS-97, COS started using containerd for creating the
toolbox container. For creating the container name, we use a combination
of username+container_image+container_image_tag. In containerd, there is
a validation that the container name should not exceed 76 characters.
However, it is possible that when the project name where the container
is hosted is long, then the container name created can exceed 76

Instead of using username+container_image+container_image_tag, we can
use username+container_image_256_hash_prefix.

TEST=locally ran the script to see that toolbox runs fine when using
long username/project_name/container_image_tag.
RELEASE_NOTE=Fixed the bug in toolbox where long project name/container
image tag can fail to run the toolbox container.

Change-Id: Ife3e696559cca6e18a8744e6ba47f3a8a2a67963
1 file changed
tree: 0b8f1a58cc38c44d78f263d37c4ee11a853ee9fe
  2. DCO
  5. README.md
  6. toolbox

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.


$ /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
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


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