From f7915452e94ee3c03c9e36df89c0b75900a18c18 Mon Sep 17 00:00:00 2001 From: Harish Karumuthil Date: Tue, 17 Oct 2023 23:33:44 +0530 Subject: [PATCH] Added cli to quickly run any linux distro as container --- home/.local/Apps/daily-utils/bin/hari-tools.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/home/.local/Apps/daily-utils/bin/hari-tools.sh b/home/.local/Apps/daily-utils/bin/hari-tools.sh index 24c5838..11c9144 100755 --- a/home/.local/Apps/daily-utils/bin/hari-tools.sh +++ b/home/.local/Apps/daily-utils/bin/hari-tools.sh @@ -12,6 +12,16 @@ list-commands(){ typeset -F | cut -d ' ' -f 3 | grep -v '^_' | sort } +# dockerLinux [imagename=ubuntu:22.40] . Quick shell inside given linux container +dockerLinux(){ + set -x + local cid=$(($RANDOM%20)) + local name=linux_$cid + local image=${1:-ubuntu:22.04} + docker run -d --name $name $image sh -c "trap : TERM INT; sleep infinity & wait" + docker exec -it $name sh +} + # ts / tsx to js/jsx tstojs(){ set -x