0

How to overwrite environment variables inside container after creation with remote API? I see no such option in container update method description. But docker itself is doing that when linking containers (source) to provide port and host variables:

DB_PORT_5432_TCP_PORT=5432
DB_PORT_5432_TCP_ADDR=172.17.0.5
...

I need to provide the same variables of other infrastructure elements which are not managed by docker. And each time I run a container this variables could be different.

I think it should look like:

  1. initialize container's dependencies.
  2. Create container itself.
  3. Run container's dependencies.
  4. Get dependencies parameters (IP, ports, etc).
  5. Configure container environment (as I thought with container update).
  6. Run container.

Steps from 3 to 6 could be repeated many times for one instance.

Paul Rumkin
  • 6,737
  • 2
  • 25
  • 35
  • Docker is _not_ doing that when linking containers. It uses DNS, not environment variables for networking. The feature currently does not exist, what's the use case? – johnharris85 Jun 27 '16 at 18:26
  • Back when Docker did use environment variables as part of linking, the variables were part of the newer container's environment; the older container's environment was untouched. There is no way to change the environment of a running container except through the process doing it itself. – jwodder Jun 27 '16 at 18:31
  • Could you not use Docker exec to run a command that updates the environment? – Nauraushaun Jun 27 '16 at 22:42
  • @JHarris Updated the question with usecase. – Paul Rumkin Jun 28 '16 at 08:19
  • @Nauraushaun actually I don't use exec. It works only on running container, doesn't it? – Paul Rumkin Jun 28 '16 at 08:21
  • @jwodder I'm not trying to update environment of running container. I need update created container somehow variables. – Paul Rumkin Jun 28 '16 at 08:29
  • @PashaRumkin that's right. But it looks like if you set the environment variables using exec, it only lasts as long as that shell. So it's probably not especially helpful in this case. – Nauraushaun Jun 28 '16 at 13:21

0 Answers0