changeset 279:d6d8468441b1

use container id's and inspect to derive projet and container names
author smith@nwoca.org
date Thu, 15 Nov 2018 19:48:02 +0000
parents 1fce27dcc359
children 7710677f147c
files scripts/.functions.sh
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/.functions.sh	Wed Nov 14 22:05:33 2018 +0000
+++ b/scripts/.functions.sh	Thu Nov 15 19:48:02 2018 +0000
@@ -34,7 +34,7 @@
 # finds docker container for specified compose service 
 composeGetContainer() {
   service=${1?"Must supply service from current project"}
-  container=$( docker-compose ps | cut -d " " -f 1 -s | grep _${service}_ )
+  container=$( docker-compose ps -q $service | xargs docker inspect -f '{{.Name}}' | cut -d "/" -f 2 )
   echo $container
 }
 
@@ -46,6 +46,6 @@
 }
 
 composeGetProject() {  
-  project=$( docker-compose ps | tail -n1 | cut -d "_" -f 1 -s )
+  project=$(docker-compose ps -q | tail -n1 |  xargs docker inspect -f "{{ index .Config.Labels \"com.docker.compose.project\"}}" )
   echo $project
 }