Skip to content

Commit

Permalink
fix: correct handling of container retrieval
Browse files Browse the repository at this point in the history
In the previous method, if the container was renamed or there were multiple names attached to the container, fetching the container ID would fail as the regex would only match at the end. Instead of using grep, use the docker 'filter' functionality to fetch the container ID as appropriate.
  • Loading branch information
josegonzalez committed Mar 25, 2019
1 parent 7864a36 commit be0dbe5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions functions
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ service_start() {
local QUIET="$2"
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
local SERVICE_NAME="$(get_service_name "$SERVICE")"
local ID=$(docker ps -f status=running --no-trunc | grep -e "$SERVICE_NAME$" | awk '{print $1}') || true
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"
return 0
fi

dokku_log_info2_quiet "Starting container"
local PREVIOUS_ID=$(docker ps -f status=exited --no-trunc | grep -e "$SERVICE_NAME$" | awk '{print $1}') || true
local PREVIOUS_ID=$(docker ps -aq --no-trunc --filter "status=exited" --filter "name=^/$SERVICE_NAME$" --format '{{ .ID }}') || true
local ROOTPASSWORD="$(cat "$SERVICE_ROOT/ROOTPASSWORD")"
local PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")"

Expand Down

0 comments on commit be0dbe5

Please sign in to comment.