You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DevOps-Bash-tools/docker.sh

42 lines
936 B
Bash

9 years ago
#!/usr/bin/env bash
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2016-02-07 22:42:47 +0000 (Sun, 07 Feb 2016)
#
# https://github.com/harisekhon/bash-tools
9 years ago
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback
#
# https://www.linkedin.com/in/harisekhon
#
[ -n "${DEBUG:-}" ] && set -x
is_docker_available(){
#[ -n "${TRAVIS:-}" ] && return 0
if which docker &>/dev/null; then
if docker info &>/dev/null; then
9 years ago
return 0
fi
fi
#echo "Docker not available"
9 years ago
return 1
}
is_docker_container_running(){
local containers="$(docker ps)"
[ -n "${DEBUG:-}" ] &&
echo "Containers Running:
$containers
"
grep -q "[[:space:]]$1$" <<< "$containers" && return 0
return 1
}
external_docker(){
[ -n "${EXTERNAL_DOCKER:-}" ] && return 0 || return 1
}