mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-30 04:33:00 +02:00
confd: add support for publishing container ports
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -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
|
||||
;;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user