https://github.com/ahmetozer/chroot-bin
execute chroot environment with symlinks
https://github.com/ahmetozer/chroot-bin
chroot golang linux
Last synced: 9 months ago
JSON representation
execute chroot environment with symlinks
- Host: GitHub
- URL: https://github.com/ahmetozer/chroot-bin
- Owner: ahmetozer
- License: apache-2.0
- Created: 2022-04-03T21:45:49.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-04-03T22:03:09.000Z (over 3 years ago)
- Last Synced: 2024-12-30T10:50:43.471Z (11 months ago)
- Topics: chroot, golang, linux
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# chroot-bin
Easily execute chrooted binnary from current environment without chroot command
For example your distroless application chroot dir is `/apps/bash/`
To execute your application, normally you can use bellow command
```bash
chroot /apps/bash/ /usr/bin/bash
```
With Chroot-bin, instead of long command, you can create link to chroot-bin
and execute directly.
```bash
ln -s /usr/bin/chroot-bin /usr/bin/bash # One time
bash
```
## Config
By default, application looks **`"/apps/"+$(basename $0)`** path for chdir.
You can change default dir by setting `CHROOTBIN_DIR_DEFAULT` variable
EX. `CHROOTBIN_DIR_DEFAULT="/myapps/"`
Currently two option is avaible for per binnary.
One of them is indicates chrootdir of the application and second one is
binnary path **inside** the chroot dir.
This helpfull if the multiple apps is under same dir.
```bash
CHROOTBIN_DIR="bash=/apps/debian;apt=/apps/debian" ./bash
```
If your link name and bin name is different, you can set custom bin path
```bash
export CHROOTBIN_DIR="ash=/apps/alpine;apk=/apps/alpine;sh=/apps/alpine" CHROOTBIN_PATH="sh=/bin/ash"
ln -s chroot-bin sh
./sh
sudo -E ./apk update
```