From 3826a75ae3060b350ecefbc0eb20b4e81786638d Mon Sep 17 00:00:00 2001 From: Jonas Bjurel Date: Wed, 7 Oct 2015 16:10:16 +0200 Subject: [PATCH] CAN MERGE VERIFIED Description: Improved handling of docker clean-up JIRA: FUEL-71 Change-Id: I565f77e227da2dcbaecd86582ab6890508726607 Signed-off-by: Jonas Bjurel --- fuel/build/docker/runcontext | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/fuel/build/docker/runcontext b/fuel/build/docker/runcontext index 52b46ad14..77e4921e1 100755 --- a/fuel/build/docker/runcontext +++ b/fuel/build/docker/runcontext @@ -1,4 +1,5 @@ #!/bin/bash +set -e ############################################################################## # Copyright (c) 2015 Ericsson AB and others. # stefan.k.berg@ericsson.com @@ -9,27 +10,43 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## # + +############################################################################ +# BEGIN of Exit handlers +# + +do_exit () { + CID=`cat $CID_FILE` + rm -f $CID_FILE + set +e + docker kill $CID > /dev/null 2>&1 + docker rm -f $CID > /dev/null 2>&1 + docker rmi -f $IID > /dev/null 2>&1 + set -e +} + +# +# End of Exit handlers +############################################################################ + +trap do_exit SIGINT SIGTERM EXIT context=$1 shift GID=`id -g` USER=`whoami` -res=`docker build -q --rm - < /dev/null -exit $rc +echo command: docker run ${RUN_CONTEXT_OPT} $IID "$@" +docker run ${RUN_CONTEXT_OPT} $IID "$@" -- 2.16.6