Created
May 29, 2018 12:22
-
-
Save HowardOhMyGod/849dc6af81172788bbd6c8f039d400d5 to your computer and use it in GitHub Desktop.
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
| #! /bin/bash | |
| # run container | |
| run () { | |
| docker run --name python -d -p 80:80 python_test | |
| } | |
| # stop and remove container | |
| stop_rm () { | |
| docker stop python | |
| docker rm python | |
| } | |
| # build new image for the latest build | |
| docker build -t python_test . | |
| # check if the production contaier is not running | |
| if [ ! "$(docker ps -q -f name=python)" ];then | |
| # cehck if the container is in docker ps -a | |
| if [ "$(docker ps -aq -f status=exited -f name=python)" ];then | |
| docker rm python | |
| fi | |
| run | |
| else | |
| stop_rm | |
| run | |
| fi | |
| # remove <none>:<none> image in docker images | |
| if [ "$(docker images -f "dangling=true" -q" ];then | |
| docker rmi $(docker images -f "dangling=true" -q) | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment