From dd66a15e02f46ecc94d5616adc438b55baaee7be Mon Sep 17 00:00:00 2001 From: Uggla Date: Mon, 18 Jan 2016 12:30:07 +0100 Subject: [PATCH] Improve docker container management - Simplify tagging. - Test removal of old container. --- dmtf/buildImage.sh | 1 - dmtf/redfish-setup.sh | 2 +- dmtf/run-redfish-simulator.sh | 11 ++++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dmtf/buildImage.sh b/dmtf/buildImage.sh index 633b886..f4a98c0 100755 --- a/dmtf/buildImage.sh +++ b/dmtf/buildImage.sh @@ -3,4 +3,3 @@ # Build and tag images docker rmi redfish-simulator docker build -t "redfish-simulator" . -docker tag -f redfish-simulator:latest localhost:5000/redfish-simulator diff --git a/dmtf/redfish-setup.sh b/dmtf/redfish-setup.sh index 63a1786..ba3f2dd 100644 --- a/dmtf/redfish-setup.sh +++ b/dmtf/redfish-setup.sh @@ -1,7 +1,7 @@ #!/bin/bash function start_apache { - [ -f "/run/apache2/apache2.pid" ] && rm "/run/apache2/apache2.pid" + [ -f "/run/apache2/apache2.pid" ] && rm -f "/run/apache2/apache2.pid" echo "Launching apache2 in foreground with /usr/sbin/apache2ctl -DFOREGROUND -k start" /usr/sbin/apache2ctl -DFOREGROUND -k start } diff --git a/dmtf/run-redfish-simulator.sh b/dmtf/run-redfish-simulator.sh index 78697c6..873e02a 100755 --- a/dmtf/run-redfish-simulator.sh +++ b/dmtf/run-redfish-simulator.sh @@ -1,8 +1,9 @@ #!/bin/bash -# Build the docker container first -docker build -t localhost:5000/redfish-simulator:latest . -# Th -p option needs to be after the run command. No warning is given if before but doesn't work -docker rm "redfish-simulator" -docker run -d -p 8000:80 --name "redfish-simulator" localhost:5000/redfish-simulator:latest +docker ps -a | grep -q "redfish-simulator:latest" +if [ "$?" -eq 0 ]; then + docker rm "redfish-simulator" +fi +# The -p option needs to be after the run command. No warning is given if before but doesn't work +docker run -d -p 8000:80 --name "redfish-simulator" redfish-simulator:latest echo "Launch your browser and load http://localhost:8000/redfish/v1"