Created
February 15, 2015 00:02
-
-
Save Ikke/ec123298318aa95b18ab to your computer and use it in GitHub Desktop.
Script to build docker images, and (re)create a container based on the image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo docker build -t $name . | |
if [[ $? -gt 0 ]] | |
then | |
exit $? | |
fi | |
echo -n "Image built, recreate container? [Yn] " | |
read answer | |
if [[ ${answer,} == n ]] | |
then | |
echo "Image created, old container kept." | |
exit 0 | |
fi | |
echo "Stopping and removing old container" | |
sudo docker stop $name 2>&1 > /dev/null | |
sudo docker rm $name 2>&1 /dev/null | |
echo done | |
echo | |
echo "Creating new container" | |
sudo docker create --name $name $args $name | |
echo done | |
echo | |
echo -n "Start new container? [Yn] " | |
read answer | |
if [[ ${answer,} != n ]] | |
then | |
sudo docker start $name | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment