Created
March 16, 2021 05:12
-
-
Save subinamathew/57e45c78d46769da53a73819131069bb to your computer and use it in GitHub Desktop.
Docker Start Stop Based on Image Name
This file contains 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 | |
# Args | |
# $1 name of the docker | |
# $2 command | |
if [ "${2}" = "start" ] | |
then | |
docker run -d -it -p 80:80 $1 | |
fi | |
if [ "${2}" = "stop" ] | |
then | |
docker stop $(docker ps -a -q --filter ancestor=$1 --format="{{.ID}}") | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment