Expose a port on a running docker container

To expose a port inside a running docker container, you can create a temporary container connected to the same network. We will use socat to link the desired port to another exposed port.

docker run --rm --net some-network -p [exposed-port]:1234 verb/socat TCP-LISTEN:1234,fork TCP-CONNECT:[container-IP]:[container-port]

Then, for example, you can ssh forward this port to your localhost 80 port: ssh -N -L 80:127.0.0.1:[exposed-port] [server-IP]

Laissez un commentaire

Votre adresse de messagerie ne sera pas publiée.

Search
Generic filters
Exact matches only
Filter by Custom Post Type