#!/usr/bin/env bash
set -e

export DOCKER_HOST=${DOCKER_HOST:-'dkhost:2376'}

#container=$(docker service ps -q --filter "desired-state=Running" sslproxy_app | head -n 1)

inspect_service() {
#  docker service ps --filter "desired-state=Running" sslproxy_app
  docker service inspect sslproxy_app
}

inspect_stack() {
  docker stack ps --filter "desired-state=Running" sslproxy
}

inspect_containers() {
  docker ps -n2
}

inspect_network() {
  docker $@
}

if [ "$1" == "service" ]; then
  inspect_service
elif [ "$1" == "stack" ]; then
  inspect_stack
elif [ "$1" == "network" ]; then
  inspect_network $@
else
  inspect_containers
fi
