| skipped 1 lines |
2 | 2 | | |
3 | 3 | | Work in progres... |
4 | 4 | | |
| 5 | + | ## Demo |
| 6 | + | |
| 7 | + | The command is very similar to `docker exec`. You point it to the target container, |
| 8 | + | potentially ask the session to be interactive (`-it`), and specify the debugging |
| 9 | + | toolkit image (`busybox` or anything starting from `nixery.dev/shell`). |
| 10 | + | |
| 11 | + | **Important:** The target container isn't recreated and/or restarted. And no extra |
| 12 | + | volumes is needed. |
| 13 | + | |
| 14 | + | Notice, how the debugger's shell actually has the original distroless rootfs as it's root directory: |
| 15 | + | |
| 16 | + | ```sh |
| 17 | + | $ docker run -d --rm \ |
| 18 | + | --name my-distroless gcr.io/distroless/nodejs \ |
| 19 | + | -e 'setTimeout(() => console.log("Done"), 99999999)' |
| 20 | + | |
| 21 | + | $ go run main.go exec -it my-distroless |
| 22 | + | {"status":"Pulling from library/busybox","id":"latest"} |
| 23 | + | {"status":"Digest: sha256:9810966b5f712084ea05bf28fc8ba2c8fb110baa2531a10e2da52c1efc504698"} |
| 24 | + | {"status":"Status: Image is up to date for busybox:latest"} |
| 25 | + | + rm -rf /proc/1/root/.cdebug |
| 26 | + | + ln -s /proc/55/root/bin/ /proc/1/root/.cdebug |
| 27 | + | + export 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/.cdebug' |
| 28 | + | + chroot /proc/1/root sh |
| 29 | + | / # ls -lah |
| 30 | + | total 60K |
| 31 | + | drwxr-xr-x 1 root root 4.0K Oct 17 23:49 . |
| 32 | + | drwxr-xr-x 1 root root 4.0K Oct 17 23:49 .. |
| 33 | + | lrwxrwxrwx 1 root root 18 Oct 17 23:49 .cdebug -> /proc/55/root/bin/ |
| 34 | + | -rwxr-xr-x 1 root root 0 Oct 17 19:49 .dockerenv |
| 35 | + | drwxr-xr-x 2 root root 4.0K Jan 1 1970 bin |
| 36 | + | drwxr-xr-x 2 root root 4.0K Jan 1 1970 boot |
| 37 | + | drwxr-xr-x 5 root root 340 Oct 17 19:49 dev |
| 38 | + | drwxr-xr-x 1 root root 4.0K Oct 17 19:49 etc |
| 39 | + | drwxr-xr-x 3 nonroot nonroot 4.0K Jan 1 1970 home |
| 40 | + | drwxr-xr-x 1 root root 4.0K Jan 1 1970 lib |
| 41 | + | drwxr-xr-x 2 root root 4.0K Jan 1 1970 lib64 |
| 42 | + | drwxr-xr-x 5 root root 4.0K Jan 1 1970 nodejs |
| 43 | + | dr-xr-xr-x 191 root root 0 Oct 17 19:49 proc |
| 44 | + | drwx------ 1 root root 4.0K Oct 17 19:55 root |
| 45 | + | drwxr-xr-x 2 root root 4.0K Jan 1 1970 run |
| 46 | + | drwxr-xr-x 2 root root 4.0K Jan 1 1970 sbin |
| 47 | + | dr-xr-xr-x 13 root root 0 Oct 17 19:49 sys |
| 48 | + | drwxrwxrwt 2 root root 4.0K Jan 1 1970 tmp |
| 49 | + | drwxr-xr-x 1 root root 4.0K Jan 1 1970 usr |
| 50 | + | drwxr-xr-x 1 root root 4.0K Jan 1 1970 var |
| 51 | + | ``` |
| 52 | + | |