added ports to docker.#Run

Signed-off-by: Richard Jones <richard@dagger.io>
This commit is contained in:
Richard Jones 2021-09-27 16:55:01 -06:00
parent 61c7837734
commit 9f16bcdadb

View File

@ -2,6 +2,7 @@
package docker package docker
import ( import (
"strings"
"alpha.dagger.io/dagger" "alpha.dagger.io/dagger"
"alpha.dagger.io/dagger/op" "alpha.dagger.io/dagger/op"
) )
@ -138,6 +139,9 @@ import (
secret: dagger.#Secret secret: dagger.#Secret
} & dagger.#Input } & dagger.#Input
// local ports
ports?: [...string]
#command: #""" #command: #"""
# Run detach container # Run detach container
OPTS="" OPTS=""
@ -146,6 +150,10 @@ import (
OPTS="$OPTS --name $CONTAINER_NAME" OPTS="$OPTS --name $CONTAINER_NAME"
fi fi
if [ ! -z "$CONTAINER_PORTS" ]; then
OPTS="$OPTS -p $CONTAINER_PORTS"
fi
docker container run -d $OPTS "$IMAGE_REF" docker container run -d $OPTS "$IMAGE_REF"
"""# """#
@ -163,6 +171,10 @@ import (
if name != _|_ { if name != _|_ {
CONTAINER_NAME: name CONTAINER_NAME: name
} }
if ports != _|_ {
CONTAINER_PORTS: strings.Join(ports," -p ")
}
} }
} }
} }