Add support for custom environment variables when starting a service container
This commit is contained in:
@@ -24,7 +24,7 @@ dokku plugin:install https://github.com/dokku/dokku-redis.git redis
|
|||||||
```
|
```
|
||||||
redis:clone <name> <new-name> Create container <new-name> then copy data from <name> into <new-name>
|
redis:clone <name> <new-name> Create container <new-name> then copy data from <name> into <new-name>
|
||||||
redis:connect <name> Connect via redis-cli to a redis service
|
redis:connect <name> Connect via redis-cli to a redis service
|
||||||
redis:create <name> Create a redis service
|
redis:create <name> Create a redis service with environment variables
|
||||||
redis:destroy <name> Delete the service and stop its container if there are no links left
|
redis:destroy <name> Delete the service and stop its container if there are no links left
|
||||||
redis:export <name> > <file> Export a dump of the redis service database
|
redis:export <name> > <file> Export a dump of the redis service database
|
||||||
redis:expose <name> [port] Expose a redis service on custom port if provided (random port otherwise)
|
redis:expose <name> [port] Expose a redis service on custom port if provided (random port otherwise)
|
||||||
@@ -53,6 +53,13 @@ dokku redis:create lolipop
|
|||||||
# official redis image
|
# official redis image
|
||||||
export REDIS_IMAGE="redis"
|
export REDIS_IMAGE="redis"
|
||||||
export REDIS_IMAGE_VERSION="2.8.21"
|
export REDIS_IMAGE_VERSION="2.8.21"
|
||||||
|
|
||||||
|
# you can also specify custom environment
|
||||||
|
# variables to start the redis service
|
||||||
|
# in semi-colon separated forma
|
||||||
|
export REDIS_CUSTOM_ENV="USER=alpha;HOST=beta"
|
||||||
|
|
||||||
|
# create a redis service
|
||||||
dokku redis:create lolipop
|
dokku redis:create lolipop
|
||||||
|
|
||||||
# get connection information as follows
|
# get connection information as follows
|
||||||
|
|||||||
7
commands
7
commands
@@ -31,8 +31,13 @@ case "$1" in
|
|||||||
touch "$LINKS_FILE"
|
touch "$LINKS_FILE"
|
||||||
|
|
||||||
dokku_log_info1 "Starting container"
|
dokku_log_info1 "Starting container"
|
||||||
|
if [[ -n $REDIS_CUSTOM_ENV ]]; then
|
||||||
|
echo "$REDIS_CUSTOM_ENV" | tr ';' "\n" > "$SERVICE_ROOT/ENV"
|
||||||
|
else
|
||||||
|
echo "" > "$SERVICE_ROOT/ENV"
|
||||||
|
fi
|
||||||
SERVICE_NAME=$(get_service_name "$SERVICE")
|
SERVICE_NAME=$(get_service_name "$SERVICE")
|
||||||
ID=$(docker run --name "$SERVICE_NAME" -v "$SERVICE_ROOT/data:/data" -v "$SERVICE_ROOT/config:/usr/local/etc/redis" -d --restart always --label dokku=service --label dokku.service=redis "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION")
|
ID=$(docker run --name "$SERVICE_NAME" -v "$SERVICE_ROOT/data:/data" -v "$SERVICE_ROOT/config:/usr/local/etc/redis" --env-file="$SERVICE_ROOT/ENV" -d --restart always --label dokku=service --label dokku.service=redis "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION")
|
||||||
echo "$ID" > "$SERVICE_ROOT/ID"
|
echo "$ID" > "$SERVICE_ROOT/ID"
|
||||||
|
|
||||||
dokku_log_verbose_quiet "Waiting for container to be ready"
|
dokku_log_verbose_quiet "Waiting for container to be ready"
|
||||||
|
|||||||
Reference in New Issue
Block a user