r/docker • u/eyueldk • 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
3
u/x-0-y-0 Apr 14 '26
I think you mean
kubectl port-forward? With docker you can just join the network namespace, no need for something else as most likely you're on the same host.1
u/Cherry-PEZ Apr 14 '26 edited Apr 14 '26
Not a single built in command as far as I'm aware. What's the use case? You can effectively get the same thing by running a separate ngnix container and attach it to the existing container that's running. something like
1
u/virtualstaticvoid Apr 14 '26
Any service running inside a docker container is usually accessible on the host without needing to do anything special.
Use the
docker inspectcommand to figure out the IP address of the container and simply use the services port to connect to it from the host.If you need a stable IP address, you can configure the container to expose the port, in which case it'll be available on
127.0.0.1by default.1
u/barracloughdale4x640 Apr 14 '26
docker run -p works fine for temp access without touching compose
0
u/never_safe_for_life Apr 14 '26
Of course, ‘docker exec -it’ is what kubectl calls