Add and delete links to a docker container dynamically

2.2k views Asked by At

I am running a flask application & with Openldap as the server. I need to add & delete links in running flask app container to openldap container. Basically I gave the link to openldap at runtime in flask app container. Now I want to add & delete openldap containers as I please & link them to flask application container without restarting it.

I am running the containers on boot2docker with docker-machine on Ubuntu 14.04.

2

There are 2 answers

1
Vitaly Isaev On

While it's still not clear why do you want to replace the openldap service on the fly, it's clear that your needs are exeeding the opportunity of --link feature. If you really need it, avoid the --link and configure a full-featured service discovery.

I will quote my own answer from the related question:

  1. Deploy some of Docker-aware DNS solutions (I suggest you to use SkyDNSv1/SkyDock);
  2. Configure your host to work with this DNS (by default SkyDNS makes the containers know each other by name, but the host is not aware of it);
  3. Run your containers with explicit --hostname (you will probably use scheme container_name.image_name.dev.skydns.local).

You will be able to start and stop different openldap containers with a similair hostname, but for Flask they will look like the same.

0
Erdal G. On

Links are now deprecated, and the new replacing feature, called "container networking" suits your needs. Take a look here: https://docs.docker.com/engine/userguide/networking/