Skip to content

Instantly share code, notes, and snippets.

@remh
Created August 1, 2016 20:06
Show Gist options
  • Save remh/6663e89d710649ff8de181e8c89e3a98 to your computer and use it in GitHub Desktop.
Save remh/6663e89d710649ff8de181e8c89e3a98 to your computer and use it in GitHub Desktop.
def setUp(self):
c = Client(version='auto')
c.pull(REDIS_DOCKER_IMAGE)
self.containers = []
def create_cont(name, host_port, args=None, link=None):
if link:
host_conf = c.create_host_config(port_bindings={6379: host_port}, links=[(link,link)])
else:
host_conf = c.create_host_config(port_bindings={6379: host_port})
cont = c.create_container(
image=REDIS_DOCKER_IMAGE,
name=name,
ports=[6379],
host_config=host_conf,
entrypoint=args
)
c.start(cont)
return cont
self.containers.append(create_cont("redis-master", 16379))
self.containers.append(create_cont("redis-auth", 26379, "redis-server --requirepass datadog-is-devops-best-friend --slaveof redis-master 6379", link="redis-master"))
self.containers.append(create_cont("redis-slave-healthy", 36379, "redis-server --slaveof redis-master 6379", link="redis-master"))
self.containers.append(create_cont("redis-slave-unhealthy", 46379, "redis-server --slaveof redis-master 55555", link="redis-master"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment