brrystrw
brrystrw

Reputation: 471

Forward docker exposed port to another port on the same container without publishing it to the host

I have a container exposing a web app through the 3000 port and another one witch access it by docker dns.

I want to access this container using the 80 port without modifying the web app and without direct exposing it to the host (aka --publish). Basically internally forward the 80 port to the 3000 port.

Is it possible to do it using docker without modifying the container to have socat or something?

Upvotes: 0

Views: 42

Answers (1)

David Maze
David Maze

Reputation: 158748

No, Docker doesn’t have this capability. The only port remapping is when a port is published outside of Docker space using the docker run -p option, and this never affects inter-service communication. Your only options here are to change the server configuration to listen on port 80, or to change the client configuration to include the explicit port 3000.

(Kubernetes Services do have this capability, and I tend to remap an unprivileged port from a given Pod to the standard HTTP port in a Service, but that’s not a core Docker capability at all.)

Upvotes: 1

Related Questions