diff --git a/board/common/rootfs/usr/sbin/container b/board/common/rootfs/usr/sbin/container index 665f926f..f7e47d77 100755 --- a/board/common/rootfs/usr/sbin/container +++ b/board/common/rootfs/usr/sbin/container @@ -1,6 +1,7 @@ #!/bin/sh all="" +port="" log() { @@ -44,8 +45,8 @@ create() fi # --syslog --log-level info - log "Calling \"podman create --name $name --conmon-pidfile=$pidfn $network $args $image\"" - if podman create --name "$name" --conmon-pidfile="$pidfn" $network $args "$image"; then + log "Calling \"podman create --name $name --conmon-pidfile=$pidfn $network $port $args $image\"" + if podman create --name "$name" --conmon-pidfile="$pidfn" $network $port $args "$image"; then log "Successfully created container $name from $image" initctl show "container:$name" |grep -q manual:yes || initctl -bq start "container:$name" initctl -nbq cond set container:$name @@ -83,6 +84,8 @@ options: --dns-search LIST Set host lookup search list when creating container -f, --force Force operation, e.g. remove -h, --help Show this help text + -p, --publish PORT Publish ports when creating container + Syntax: [[ip:][hostPort]:]containerPort[/protocol] -s, --simple Show output in simplified format commands: @@ -119,6 +122,10 @@ while [ "$1" != "" ]; do usage exit 0 ;; + -p | --publish) + shift + port="$port -p $1" + ;; -s | --simple) simple=true ;; diff --git a/src/confd/src/infix-containers.c b/src/confd/src/infix-containers.c index 14c78e4d..7edeae1c 100644 --- a/src/confd/src/infix-containers.c +++ b/src/confd/src/infix-containers.c @@ -52,6 +52,9 @@ static int add(const char *name, struct lyd_node *cif) LYX_LIST_FOR_EACH(lyd_child(cif), node, "search") fprintf(fp, " --dns-search %s", lyd_get_value(node)); + LYX_LIST_FOR_EACH(lyd_child(cif), node, "publish") + fprintf(fp, " -p %s", lyd_get_value(node)); + fprintf(fp, " create %s %s", name, image); LYX_LIST_FOR_EACH(lyd_child(cif), node, "network") { diff --git a/src/confd/yang/infix-containers@2023-12-14.yang b/src/confd/yang/infix-containers@2023-12-14.yang index 3805adb9..89320fcf 100644 --- a/src/confd/yang/infix-containers@2023-12-14.yang +++ b/src/confd/yang/infix-containers@2023-12-14.yang @@ -116,7 +116,11 @@ module infix-containers { } leaf-list publish { - description "Publish container port, or a range of ports, to the host."; + description "Publish container port, or a range of ports, to the host. + Syntax: [[ip:][hostPort]:]containerPort[/protocol] + Sample: 8080:80 -- forward tcp port 8080 to container port 80 + 69:69/udp -- forward udp port 69 to container port 69 + 127.0.0.1:8080:80 -- forward only from loopback interface"; type string; }