Skip to content

Instantly share code, notes, and snippets.

@akkerman
Created June 12, 2021 07:10
Show Gist options
  • Save akkerman/f4bc1288c981cb0c10cd47bb6c212b41 to your computer and use it in GitHub Desktop.
Save akkerman/f4bc1288c981cb0c10cd47bb6c212b41 to your computer and use it in GitHub Desktop.
Wraps the docker command to add some functionality
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