Skip to content

Instantly share code, notes, and snippets.

@subinamathew
Created March 16, 2021 05:12
Show Gist options
  • Save subinamathew/57e45c78d46769da53a73819131069bb to your computer and use it in GitHub Desktop.
Save subinamathew/57e45c78d46769da53a73819131069bb to your computer and use it in GitHub Desktop.
Docker Start Stop Based on Image Name
#/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