confd: add support for publishing container ports

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2024-02-25 19:49:27 +01:00
parent b04c81199d
commit 3d85eba3fc
3 changed files with 17 additions and 3 deletions
+9 -2
View File
@@ -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
;;
+3
View File
@@ -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") {
@@ -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;
}