diff --git a/board/common/rootfs/usr/sbin/container b/board/common/rootfs/usr/sbin/container index 9bd59f7d..5bd21106 100755 --- a/board/common/rootfs/usr/sbin/container +++ b/board/common/rootfs/usr/sbin/container @@ -26,9 +26,6 @@ create() # args="$args --log-opt tag=$name" pidfn=/run/container:${name}.pid - for net in "$@"; do - network="$network --net $net" - done log "---------------------------------------" log "Got name: $name image: $image" log "Got networks: $network" @@ -47,9 +44,10 @@ create() # --syslog --log-level info log "Calling \"podman create --name $name --conmon-pidfile=$pidfn $hostname $env $network $port $args $image\"" + set -x if podman create --name "$name" --conmon-pidfile="$pidfn" $hostname $env $network $port $args "$image"; then log "Successfully created container $name from $image" - rm "/run/containers/env/${name}.env" + rm -f "/run/containers/env/${name}.env" initctl show "container:$name" |grep -q manual:yes || initctl -bq start "container:$name" initctl -nbq cond set container:$name exit 0 @@ -88,6 +86,7 @@ options: -f, --force Force operation, e.g. remove -h, --help Show this help text --hostname NAME Set hostname when creating container + --net NETWORK Set network(s) when creating container -p, --publish PORT Publish ports when creating container Syntax: [[ip:][hostPort]:]containerPort[/protocol] -s, --simple Show output in simplified format @@ -134,6 +133,10 @@ while [ "$1" != "" ]; do shift hostname="--hostname $1" ;; + --net) + shift + network="$network --net $1" + ;; -p | --publish) shift port="$port -p $1" diff --git a/src/confd/src/infix-containers.c b/src/confd/src/infix-containers.c index 820bdbca..c24e8c6a 100644 --- a/src/confd/src/infix-containers.c +++ b/src/confd/src/infix-containers.c @@ -68,15 +68,13 @@ static int add(const char *name, struct lyd_node *cif) fprintf(fp, " -e /run/containers/env/%s.env", name); } - fprintf(fp, " create %s %s", name, image); - LYX_LIST_FOR_EACH(lyd_child(cif), node, "network") { struct lyd_node *opt; const char *name; int first = 1; name = lydx_get_cattr(node, "name"); - fprintf(fp, " %s", name); + fprintf(fp, " --net %s", name); LYX_LIST_FOR_EACH(lyd_child(node), opt, "option") { const char *option = lyd_get_value(opt); @@ -86,7 +84,9 @@ static int add(const char *name, struct lyd_node *cif) } if (lydx_is_enabled(cif, "host-network")) - fprintf(fp, " host"); + fprintf(fp, " --net host"); + + fprintf(fp, " create %s %s", name, image); fprintf(fp, "\n"); fchmod(fileno(fp), 0700);