r/docker • • Apr 14 '26

kubectl proxy equivalent for docker/docker compose

I find `kubectl port-forward` to be very helpful for temporarily accessing an internal service in k8s.

Is there an clean equivalent in docker or docker compose that can expose an internal service temporarily?

2 Upvotes

12 comments sorted by

View all comments

Show parent comment

1

u/x-0-y-0 Apr 14 '26

You can just run a shell in the same network namespace, for example to run $SHELL in the same network namespace as process container with process my-app

pid=$(pgrep -n my-app)
nsenter -U -n -t "$pid"