Skip to content

Instantly share code, notes, and snippets.

@hazbo
Created January 30, 2015 14:34
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save hazbo/67735884dfa9c2dfaf6e to your computer and use it in GitHub Desktop.
Save hazbo/67735884dfa9c2dfaf6e to your computer and use it in GitHub Desktop.
A small script to remove (force) a container if it exists
#!/bin/bash
CONTAINER=$1
RUNNING=$(docker inspect --format="{{ .State.Running }}" $CONTAINER 2> /dev/null)
if [ $? -eq 1 ]; then
echo "'$CONTAINER' does not exist."
else
/usr/bin/docker rm --force $CONTAINER
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment