From e6244aeedc1124520c0cb5ce2c8d95063f51ed8b Mon Sep 17 00:00:00 2001 From: sw360cab Date: Thu, 18 Nov 2021 16:54:12 +0100 Subject: [PATCH] Add Feature to leverage custom command inside Docker.#Run Signed-off-by: Sergio Maria Matone --- pkg/alpha.dagger.io/docker/docker.cue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/alpha.dagger.io/docker/docker.cue b/pkg/alpha.dagger.io/docker/docker.cue index 36021d31..3b288f5c 100644 --- a/pkg/alpha.dagger.io/docker/docker.cue +++ b/pkg/alpha.dagger.io/docker/docker.cue @@ -214,6 +214,9 @@ import ( // Container name name?: dagger.#Input & {string} + // Custom Command overriding entrypoint of the Image + containerCommand?: dagger.#Input & {string} + // Recreate container? recreate: dagger.#Input & {bool | *true} @@ -230,6 +233,7 @@ import ( #command: #""" # Run detach container OPTS="" + CMD="" if [ ! -z "$CONTAINER_NAME" ]; then OPTS="$OPTS --name $CONTAINER_NAME" @@ -250,7 +254,11 @@ import ( OPTS="$OPTS -p $CONTAINER_PORTS" fi - docker container run -d $OPTS "$IMAGE_REF" + if [ ! -z "$CONTAINER_CMD" ]; then + CMD="$CONTAINER_CMD" + fi + + docker container run -d $OPTS "$IMAGE_REF" $CMD """# run: #Command & { @@ -278,6 +286,11 @@ import ( if ports != _|_ { CONTAINER_PORTS: strings.Join(ports, " -p ") } + + if containerCommand != _|_ { + CONTAINER_CMD: containerCommand + } + } } }