8000 hakoniwa/hakoniwa-cli at main · gominimal/hakoniwa · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
 
 

hakoniwa-cli

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Hakoniwa-CLI

Usage

hakoniwa run -v \
  --unshare-all \
  --rootfs / --devfs /dev --tmpfs /tmp \
  -- dd if=/dev/random of=/tmp/output.txt count=1 bs=4
  • hakoniwa run -v
    • Run a COMMAND in a container. By default, it will
    • Create a new MOUNT namespace
    • Create a new USER namespace and map current user to itself
    • Create a new PID namespace and mount a new procfs on /proc
    • With -v to show logging output
  • --unshare-all
    • Create new CGROUP, IPC, NETWORK, UTS, ... namespaces
  • --rootfs / --devfs /dev --tmpfs /tmp
    • Bind mount /bin, /lib, /etc, /usr, ... with read-only access if exists
    • Mount devfs on /dev, it contains a minimal set of device files, like /dev/null
    • Mount tmpfs on /tmp
  • -- dd if=/dev/random of=/tmp/output.txt count=1 bs=4
    • Exec COMMAND dd if=/dev/random of=/tmp/output.txt count=1 bs=4

In most cases, you can just use following code (--rootfs=/ is enabled by default):

hakoniwa run --unshare-all --devfs /dev --tmpfs /tmp -- ls -lah

For TUI app, run with -e TERM:

hakoniwa run --unshare-all --devfs /dev --tmpfs /tmp -e TERM -- top

For static linked binaries, it is not necassary to mount system-wide directories, run with --rootfs=none:

hakoniwa run --unshare-all --devfs /dev --tmpfs /tmp --rootfs=none -b /mybin -- /mybin/static-linked-binaries-COMMAND

Want to access network, run with --network=pasta:

hakoniwa run --unshare-all --devfs /dev --tmpfs /tmp --network=pasta -- wget https://example.com --spider

Want to restrict process resource usage, run with --limit-xxxx:

hakoniwa run --unshare-all --devfs /dev --tmpfs /tmp --limit-walltime 1 -- sleep 2

By default, it always loads a Podman-compatible seccomp profile, want to use a customized profile, run with --seccomp=myprofile.toml:

hakoniwa run --unshare-all --devfs /dev --tmpfs /tmp --seccomp=myprofile.toml -- ls

Want to see what features are enabled, use -v or -vv to display the logging output:

hakoniwa run --unshare-all --devfs /dev --tmpfs /tmp -v -- ls

If the command line is too long, too complex, you can create a profile and run with --config:

hakoniwa run -c myprofile.toml

the COMMAND can be overridden:

hakoniwa run -c myprofile.toml -- another-COMMAND

More Examples

Command Reference

Troubleshooting

If you receive hakoniwa: write("/proc/self/uid_map", ...) => Operation not permitted (os error 1), read following docs:

If you experience a DNS lookup failure, read following docs:

0