Skip to content

Instantly share code, notes, and snippets.

@pnathan
Created October 16, 2015 03:29
Show Gist options
  • Select an option

  • Save pnathan/5f6666ccc47f2d0a4142 to your computer and use it in GitHub Desktop.

Select an option

Save pnathan/5f6666ccc47f2d0a4142 to your computer and use it in GitHub Desktop.
keep-those-containers-running
#!/bin/bash
# downloads docker container.
running_id=$(docker ps | grep "$1" | cut -f1 -d' ')
docker pull "$1" | grep 'up to date'
if [[ "$?" -eq "1" ]]; then
docker kill $running_id
fi
docker ps | grep $1
if [[ "$?" -eq "1" ]]; then
docker run -d -e "VIRTUAL_HOST=$2" "$1"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment