Skip to content

Instantly share code, notes, and snippets.

@shykes
Last active December 30, 2015 04:29
Show Gist options
  • Save shykes/7776351 to your computer and use it in GitHub Desktop.
Save shykes/7776351 to your computer and use it in GitHub Desktop.

Simple ambassador container

The Simple Ambassador Container (let's just call it the ambassador) is a reusable container which can be added to your stack to represent a remote service. Using an ambassador your application can discover remote services using docker's standard links features.

Usage

Example usage:

REDIS_REMOTE_IP=1.2.3.4
REDIS_REMOTE_PORT=4242
docker run -d -name remote_redis ambassador 3679:1.2.3.4:4242/tcp
docker run -link remote_redis:redis myapp

This creates a new container from the ambassador image, configuring it to listen on tcp port 3679 and forward connections to 1.2.3.4:4242. This particular ambassador container is called remote_redis but it could be called anything.

Then a new container is created from the myapp image, and the ambassador container is made discoverable to the application as redis. The application can now use regular links discovery to connect to its redis database.

Implementation

Any proxy software can be used which supports tcp and udp. A good starting point is socat which can very easily implement any proxy scenario from the command-line without complex configuration.

If socat is not sufficient, a more full-featured proxy can be used, like haproxy or nginx.

@SvenDowideit
Copy link

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