#!/bin/bash

# Start a docker netshoot container

set -eu

main ()
{
  local container=${1-}
  local img=${2:-nicolaka/netshoot}
  local args=
  local opts=

  if [[ -n "$container" ]]; then
    opts="--network container:$container"
  fi
  if [[ "$container" == "$img" ]]; then
    img=$(docker inspect --format='{{.Image}}' "$container")
  fi

  docker run --rm -ti -v "$HOME/.cache/netshoot:/root" $opts $img /bin/bash
}

main $@

