fix: ensure the tracked container id is up to date

If the ID file contained an incorrect value, calling :start would say the service is started but :info would still show the container as missing.

Also fix an issue where docker inspect leaked stderr when the container was missing.

Refs dokku/dokku-redis#133
This commit is contained in:
Jose Diaz-Gonzalez
2019-06-11 15:44:20 -04:00
parent 358f7068ba
commit 0c4db51565
2 changed files with 5 additions and 1 deletions

View File

@@ -121,6 +121,10 @@ service_start() {
local ID=$(docker ps -aq --no-trunc --filter "status=running" --filter "name=^/$SERVICE_NAME$" --format '{{ .ID }}') || true
if [[ -n $ID ]]; then
[[ -z $QUIET ]] && dokku_log_warn "Service is already started"
if [[ ! -f "$SERVICE_ROOT/ID" ]] || [[ "$(cat "$SERVICE_ROOT/ID")" != "$ID" ]]; then
[[ -z $QUIET ]] && dokku_log_warn "Updating local container ID"
echo "$ID" >"$SERVICE_ROOT/ID"
fi
return 0
fi