Label running containers

This will avoid issues where `dokku cleanup` removes the stopped containers (it should not do so, and instead should allow them to stay in stopped mode).

Containers will be labeled as follows:

- service: dokku=service dokku.service=SERVICE_NAME
- ambassador: dokku=ambassador dokku.ambassador=SERVICE_NAME

To destroy the containers, simply run the `service:destroy` command.
This commit is contained in:
Jose Diaz-Gonzalez
2015-09-06 19:29:28 -04:00
parent 2289c5f3dc
commit f72bf5402d
2 changed files with 2 additions and 2 deletions

View File

@@ -36,7 +36,7 @@ case "$1" in
dokku_log_info1 "Starting container"
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 "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION")
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")
echo "$ID" > "$SERVICE_ROOT/ID"
dokku_log_verbose_quiet "Waiting for container to be ready"

View File

@@ -175,7 +175,7 @@ service_port_unpause() {
echo "${PORTS[@]}" > "$PORT_FILE"
docker run -d --link "$SERVICE_NAME:redis" --name "$EXPOSED_NAME" $(docker_ports_options "${PORTS[@]}") --restart always svendowideit/ambassador > /dev/null
docker run -d --link "$SERVICE_NAME:redis" --name "$EXPOSED_NAME" $(docker_ports_options "${PORTS[@]}") --restart always --label dokku=ambassador --label dokku.ambassador=redis svendowideit/ambassador > /dev/null
if [[ "$LOG_FAIL" == "true" ]]; then
dokku_log_info1 "Service $SERVICE exposed on port(s) ${PORTS[*]}"
fi