Add support for environment variables
This commit is contained in:
parent
1493035702
commit
defe99b4ac
@ -165,6 +165,7 @@ function docker-env() {
|
|||||||
port=
|
port=
|
||||||
workdir=/work_dir
|
workdir=/work_dir
|
||||||
volumes=("$(pwd):/work_dir")
|
volumes=("$(pwd):/work_dir")
|
||||||
|
envvars=()
|
||||||
|
|
||||||
while
|
while
|
||||||
do
|
do
|
||||||
@ -177,6 +178,10 @@ function docker-env() {
|
|||||||
port="$2"
|
port="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-e)
|
||||||
|
envvars+=("$2")
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-v)
|
-v)
|
||||||
volumes+=("$2")
|
volumes+=("$2")
|
||||||
shift
|
shift
|
||||||
@ -204,6 +209,7 @@ Usage: docker-env [OPTIONS] [--] IMAGE [COMMAND] [ARG...]
|
|||||||
|
|
||||||
Options:
|
Options:
|
||||||
-p <port> Publish a container's port(s) to the host
|
-p <port> Publish a container's port(s) to the host
|
||||||
|
-e VAR=value Add environment variable VAR with value
|
||||||
-v <volume> Bind mount a volume
|
-v <volume> Bind mount a volume
|
||||||
EOS
|
EOS
|
||||||
return 1
|
return 1
|
||||||
@ -227,6 +233,10 @@ EOS
|
|||||||
do
|
do
|
||||||
run_command+=" -v $volume"
|
run_command+=" -v $volume"
|
||||||
done
|
done
|
||||||
|
for envvar in $envvars
|
||||||
|
do
|
||||||
|
run_command+=" -e \"$envvar\""
|
||||||
|
done
|
||||||
|
|
||||||
run_command+=" -w \"$workdir\" $image $cmd"
|
run_command+=" -w \"$workdir\" $image $cmd"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user