From 0c4db51565f5df44391bb25c0f7e02f55cf18515 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 11 Jun 2019 15:44:20 -0400 Subject: [PATCH] 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 --- common-functions | 2 +- functions | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/common-functions b/common-functions index 7948099..d770be5 100755 --- a/common-functions +++ b/common-functions @@ -14,7 +14,7 @@ docker_ports_options() { get_container_ip() { declare desc="Retrieves the ip address of a container" declare CONTAINER_ID="$1" - docker inspect --format '{{ .NetworkSettings.IPAddress }}' "$CONTAINER_ID" + docker inspect --format '{{ .NetworkSettings.IPAddress }}' "$CONTAINER_ID" 2>/dev/null } get_database_name() { diff --git a/functions b/functions index e0ff092..7f8c7f9 100755 --- a/functions +++ b/functions @@ -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