Created
June 12, 2021 07:10
-
-
Save akkerman/f4bc1288c981cb0c10cd47bb6c212b41 to your computer and use it in GitHub Desktop.
Wraps the docker command to add some functionality
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
function docker() { | |
case "$1" in | |
ip) | |
command docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "${@:2}" | |
;; | |
env) | |
command docker inspect --format '{{json .Config.Env}}' "${@:2}" | jq | |
;; | |
service) | |
if [ "$2" = env ]; then | |
command docker service inspect -f "{{json .Spec.TaskTemplate.ContainerSpec.Env}}" "${@:3}" | jq | |
else | |
command docker "$@" | |
fi | |
;; | |
*) | |
command docker "$@" | |
;; | |
esac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment