Skip to content

Instantly share code, notes, and snippets.

@laudai
Forked from hazbo/check-container.sh
Created May 1, 2018 11:34
Show Gist options
  • Save laudai/5140bc0eae31db1bc4b0125630e6e00d to your computer and use it in GitHub Desktop.
Save laudai/5140bc0eae31db1bc4b0125630e6e00d 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