Skip to content

Instantly share code, notes, and snippets.

@crosbymichael
Last active December 23, 2015 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save crosbymichael/6557161 to your computer and use it in GitHub Desktop.
Save crosbymichael/6557161 to your computer and use it in GitHub Desktop.
Docker links
REDIS=$(docker run -d crosbymichael/redis)
docker run -link $REDIS:6379:redis -t -i 71cba4d74d62 bash
root@7c1879d423b6:/# cat app.py
import docker
from redis import Redis
ip, port = docker.require('redis')
r = Redis(host=ip, port=int(port))
r.set('crosbymichael', 'Is amazing')
print r.get('crosbymichael')
root@7c1879d423b6:/# python app.py
Is amazing
root@7c1879d423b6:/# exit
docker link $REDIS
FROM TO ADDRESS ALIAS
52050b536cb6 7c1879d423b6 172.17.0.2:6379 redis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment