Docker container
docker exec -it <container name> /bin/bash
Kubernetes
kubectl exec --stdin --tty <pod name> -- /bin/bash
Opening a shell when a Pod has more than one container
kubectl exec -i -t <pod name> --container <container name> -- /bin/bash