Created
December 3, 2020 10:47
-
-
Save atomatt/94bf0b8222bd19865991f2f0e61bd342 to your computer and use it in GitHub Desktop.
TCP proxy from host to service port in a docker container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -eu | |
| network="${1:?network is required}" | |
| service_name="${2:?service name is required}" | |
| service_port="${3:?service port is required}" | |
| host_port="${4:-${service_port}}" | |
| docker run --rm \ | |
| --network "${network}" \ | |
| -p "${host_port}":"${service_port}" \ | |
| nixery.dev/socat socat \ | |
| "TCP-LISTEN:${service_port},fork" "TCP:${service_name}:${service_port}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment