Kubernetes

kubectl -n $namespace exec -it $pod -- /bin/bash

note Double-dash The double dash (--) separates the args passed to the command from the kubectl args

Docker

docker exec -it $container /bin/bash