Created
February 23, 2017 15:25
-
-
Save clcollins/ab9f64a7c772794a165e69ee30aaa5ad to your computer and use it in GitHub Desktop.
Wrapper to handle Docker TLS connection flags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
usage () { | |
cat << EOF | |
Usage: dkr HOSTNAME | |
dkr HOSTNAME COMMAND [arg...] | |
A wrapper around Docker to simplify using TLS connections | |
In the first form, will watch the output of "docker ps" and "docker images" on the remote host. | |
In the second form, will execute whichever Docker command is specified. | |
EOF | |
} | |
main () { | |
local fqdn="${1}" | |
local cmd="${@:2}" | |
case $fqdn in | |
'--help') | |
usage | |
exit 0 | |
;; | |
*) | |
local dkr="docker -H ${fqdn}:2376" | |
export DOCKER_TLS_VERIFY=1 | |
esac | |
if [[ -z ${cmd} ]] | |
then | |
exec watch "${dkr} ps ; ${dkr} images" | |
else | |
exec ${dkr} ${cmd} | |
fi | |
exit 0 | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment