Skip to content

Instantly share code, notes, and snippets.

@benschw
Created December 16, 2013 00:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benschw/7980697 to your computer and use it in GitHub Desktop.
Save benschw/7980697 to your computer and use it in GitHub Desktop.
socat docker ambassador
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 SvenDowideit@home.org.au
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