containers / containers/toolbox
Improve the error message when running nested inside a non-Toolbx container
- Dominant language
- Go
- Stars
- 3.5k
- Forks
- 262
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 1
Description
Toolbx can run nested inside Toolbx containers:
```
[rishi@topinka ~]$ toolbox enter
⬢[rishi@toolbox ~]$ toolbox list
IMAGE ID IMAGE NAME CREATED
e085805ade4a registry.access.redhat.com/ubi8/toolbox:latest 5 months ago
4537d20059a4 registry.access.redhat.com/ubi9/toolbox:latest 5 months ago
1c8862ef037f registry.fedoraproject.org/fedora-toolbox:35 4 months ago
2110dbbc33d2 registry.fedoraproject.org/fedora-toolbox:36 4 months ago
CONTAINER ID CONTAINER NAME CREATED STATUS IMAGE NAME
6167f42745fe fedora-toolbox-36 3 weeks ago running registry.fedoraproject.org/fedora-toolbox:36
```
However, it's not supposed to run inside random non-Toolbx containers. Regardless, people still try to run it (see https://github.com/containers/toolbox/issues/989) and the error message in such cases isn't very good.
This is what happens:
```
[rishi@topinka ~]$ podman run -it --rm registry.fedoraproject.org/fedora:37 /bin/bash
[root@bcc4a951f32c /]# sudo dnf -y install toolbox
...
...
[root@bcc4a951f32c /]# ln -s ../ /run/host
[root@bcc4a951f32c /]# toolbox
Error: TOOLBOX_PATH not set
[root@bcc4a951f32c /]# export TOOLBOX_PATH=/usr/bin/toolbox
[root@bcc4a951f32c /]# toolbox list
Error: this is not a toolbox container
```
It will be good if we could improve the error handling so that the problem is more obvious (eg., the problem with `TOOLBOX_PATH` is secondary here) and self-explanatory like our other error messages (see `src/cmd/utils.go`).
Something like this:
```
[rishi@topinka ~]$ podman run -it --rm registry.fedoraproject.org/fedora:37 /bin/bash
[root@bcc4a951f32c /]# sudo dnf -y install toolbox
...
...
[root@bcc4a951f32c /]# ln -s ../ /run/host
[root@bcc4a951f32c /]# toolbox
Error: this is not a Toolbox container
Toolbox is only meant to work with Toolbox containers.
Run 'toolbox --help' for usage.
[root@bcc4a951f32c /]# toolbox list
Error: this is not a Toolbox container
Toolbox is only meant to work with Toolbox containers.
Run 'toolbox --help' for usage.
```
Note that the `ln` invocation will still be necessary. It's beyond the limits of this issue.
Contributor guide
Assessment
This issue has not been assessed yet.