diff --git a/board/common/rootfs/usr/sbin/container b/board/common/rootfs/usr/sbin/container index 5bd21106..72ed7151 100755 --- a/board/common/rootfs/usr/sbin/container +++ b/board/common/rootfs/usr/sbin/container @@ -43,9 +43,10 @@ create() fi # --syslog --log-level info - log "Calling \"podman create --name $name --conmon-pidfile=$pidfn $hostname $env $network $port $args $image\"" + log "Calling \"podman create --name $name --conmon-pidfile=$pidfn $hostname $entrypoint $env $network $port $args $image $*\"" set -x - if podman create --name "$name" --conmon-pidfile="$pidfn" $hostname $env $network $port $args "$image"; then + # shellcheck disable=SC2048 + if podman create --name "$name" --conmon-pidfile="$pidfn" $hostname $entrypoint $env $network $port $args "$image" $*; then log "Successfully created container $name from $image" rm -f "/run/containers/env/${name}.env" initctl show "container:$name" |grep -q manual:yes || initctl -bq start "container:$name" @@ -83,6 +84,7 @@ options: --dns NAMESERVER Set nameserver(s) when creating a container --dns-search LIST Set host lookup search list when creating container -e, --env FILE Environment variables when creating container + --entrypoint Disable container image's ENTRYPOINT, run cmd + arg -f, --force Force operation, e.g. remove -h, --help Show this help text --hostname NAME Set hostname when creating container @@ -122,6 +124,9 @@ while [ "$1" != "" ]; do shift env="$env --env-file=$1" ;; + --entrypoint) + entrypoint="--entrypoint=\"\"" + ;; -f | --force) force="-f" ;; diff --git a/src/confd/src/infix-containers.c b/src/confd/src/infix-containers.c index c24e8c6a..98019e67 100644 --- a/src/confd/src/infix-containers.c +++ b/src/confd/src/infix-containers.c @@ -86,8 +86,14 @@ static int add(const char *name, struct lyd_node *cif) if (lydx_is_enabled(cif, "host-network")) fprintf(fp, " --net host"); + if ((string = lydx_get_cattr(cif, "entrypoint"))) + fprintf(fp, " --entrypoint"); + fprintf(fp, " create %s %s", name, image); + if ((string = lydx_get_cattr(cif, "entrypoint"))) + fprintf(fp, " %s", string); + fprintf(fp, "\n"); fchmod(fileno(fp), 0700); fclose(fp); diff --git a/src/confd/yang/infix-containers@2023-12-14.yang b/src/confd/yang/infix-containers@2023-12-14.yang index c86f0f33..80ab3e51 100644 --- a/src/confd/yang/infix-containers@2023-12-14.yang +++ b/src/confd/yang/infix-containers@2023-12-14.yang @@ -83,6 +83,11 @@ module infix-containers { } } + leaf entrypoint { + description "Override the default ENTRYPOINT from the image."; + type string; + } + leaf hostname { description "Sets the container host name that is available inside the container."; type inet:domain-name;