Skip to content

Instantly share code, notes, and snippets.

@Eddy-Barraud
Created April 13, 2020 13:48
Show Gist options
  • Save Eddy-Barraud/e2f830db2d1173025809a84cff8cddb9 to your computer and use it in GitHub Desktop.
Save Eddy-Barraud/e2f830db2d1173025809a84cff8cddb9 to your computer and use it in GitHub Desktop.

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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment