Created
December 16, 2013 00:46
-
-
Save benschw/7980697 to your computer and use it in GitHub Desktop.
socat docker ambassador
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
The svendowideit/ambassador Dockerfile | |
The svendowideit/ambassador image is a small busybox image with socat built in. When you start the container, it uses a small sed script to parse out the (possibly multiple) link environment variables to set up the port forwarding. On the remote host, you need to set the variable using the -e command line option. | |
-expose 1234 -e REDIS_PORT_1234_TCP=tcp://192.168.1.52:6379 will forward the local 1234 port to the remote IP and port - in this case 192.168.1.52:6379. | |
# | |
# | |
# first you need to build the docker-ut image using ./contrib/mkimage-unittest.sh | |
# then | |
# docker build -t SvenDowideit/ambassador . | |
# docker tag SvenDowideit/ambassador ambassador | |
# then to run it (on the host that has the real backend on it) | |
# docker run -t -i -link redis:redis -name redis_ambassador -p 6379:6379 ambassador | |
# on the remote host, you can set up another ambassador | |
# docker run -t -i -name redis_ambassador -expose 6379 sh | |
FROM docker-ut | |
MAINTAINER [email protected] | |
CMD env | grep _TCP= | \ | |
sed 's/.*_PORT_\([0-9]*\)_TCP=tcp:\/\/\(.*\):\(.*\)/socat \ | |
TCP4-LISTEN:\1,fork,reuseaddr TCP4:\2:\3 \&/' \ | |
| sh && top |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment