From cf225129a51e7f86c2bfbee18fa343cd0c7121a4 Mon Sep 17 00:00:00 2001 From: filih Date: Wed, 23 Oct 2024 09:09:50 +0200 Subject: [PATCH] added expose-nets --- doc/git-log.txt | 1 + run/__ | 1 + run/__v | 6 ++++++ run/__vp | 7 +++++++ script/expose-netns.sh | 24 ++++++++++++++++++++++++ 5 files changed, 39 insertions(+) create mode 100644 doc/git-log.txt create mode 100644 run/__ create mode 100644 run/__v create mode 100644 run/__vp create mode 100644 script/expose-netns.sh diff --git a/doc/git-log.txt b/doc/git-log.txt new file mode 100644 index 0000000..efcc525 --- /dev/null +++ b/doc/git-log.txt @@ -0,0 +1 @@ +git submodule add -b z1 http://t:f6ad1fe79d0b929d8def3339dafcbf919f311acf@qstack.pl:3000/c2023/p22.10 app diff --git a/run/__ b/run/__ new file mode 100644 index 0000000..a3f5eef --- /dev/null +++ b/run/__ @@ -0,0 +1 @@ +f() { sudo docker run --rm -dit --privileged --name "$1" deb su - user; }; f deb1 diff --git a/run/__v b/run/__v new file mode 100644 index 0000000..4ce68e8 --- /dev/null +++ b/run/__v @@ -0,0 +1,6 @@ +f() { + sudo docker run --rm -dit --privileged \ + -v "$(pwd)/app:/home/user/work" \ + --name "$1" deb su - user; +}; +f $1 diff --git a/run/__vp b/run/__vp new file mode 100644 index 0000000..41e072b --- /dev/null +++ b/run/__vp @@ -0,0 +1,7 @@ +f() { + sudo docker run --rm -dit --privileged \ + -v "$(pwd)/app:/home/user/work" \ + -p 3333:3333 \ + --name "$1" deb su - user; +}; +f $1 diff --git a/script/expose-netns.sh b/script/expose-netns.sh new file mode 100644 index 0000000..011e381 --- /dev/null +++ b/script/expose-netns.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +if [ $# -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +echo "expose container $1 netns" +NETNS=`sudo docker inspect -f '{{.State.Pid}}' $1` + +if [ ! -d /var/run/netns ]; then + sudo mkdir /var/run/netns +fi +if [ -f /var/run/netns/$NETNS ]; then + sudo rm -rf /var/run/netns/$NETNS +fi + +sudo ln -s /proc/$NETNS/ns/net /var/run/netns/$NETNS +echo "done. netns: $NETNS" + +echo "=============================" +echo "current network namespaces: " +echo "=============================" +ip netns