Pass environment variables to docker container

This change allows arbitrary environment variables to be passed to the
underlying docker container. Useful when using postgres docker
containers which allow for additional configuration on top of the
official postgres image.

See https://github.com/mcolyer/docker-postgres-wale for an example.
This commit is contained in:
Matt Colyer
2015-10-26 21:05:53 -07:00
parent 8f392acf22
commit 3c1c8f9e80
2 changed files with 6 additions and 2 deletions

View File

@@ -31,8 +31,12 @@ case "$1" in
touch "$LINKS_FILE"
dokku_log_info1 "Starting container"
ENVIRONMENT=""
for arg in "${@:2}"; do
ENVIRONMENT="$ENVIRONMENT -e $arg"
done
SERVICE_NAME=$(get_service_name "$SERVICE")
ID=$(docker run --name "$SERVICE_NAME" -v "$SERVICE_ROOT/data:/var/lib/postgresql/data" -e "POSTGRES_PASSWORD=$password" -d --restart always --label dokku=service --label dokku.service=postgres "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION")
ID=$(docker run --name "$SERVICE_NAME" -v "$SERVICE_ROOT/data:/var/lib/postgresql/data" $ENVIRONMENT -e "POSTGRES_PASSWORD=$password" -d --restart always --label dokku=service --label dokku.service=postgres "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION")
echo "$ID" > "$SERVICE_ROOT/ID"
dokku_log_verbose_quiet "Waiting for container to be ready"