0

Im trying to link two containers to one app, and want to reference those apps hostname/url in an env.

Then the main application can run, but i cannot manage to get the values properly.

Dockerfile of main app contains this

ENV APP1_URL app1

ENV APP2_URL app2

When running

docker run -d -p 22222:3000 --link app1:app1 app2:app2 --name mainapp user/image

Main app needs those env to run, how can i get those values?

abFx
  • 313
  • 3
  • 14
  • `app1_url=$(docker exec -it container_id echo $APP1_URL)` same logic for the second one, and then `docker run -e app1=$app1_url` and so – user2915097 Apr 05 '16 at 09:44
  • This would depend on the language of your main app, but in general these are just like any other environment variables – Xiongbing Jin Apr 05 '16 at 14:04
  • if you get inside the main app ... docker exec -it mainapp bash ... and then run the linux command ... env ... what environment vairables do you see, any you need? – danday74 Apr 05 '16 at 17:28
  • actually i was trying to replace an env var of my app with the one that docker generates during the linking (in the dockerfile), but couldnt figure out how... I ended using docker env generated ones... such as app_port_addr... – abFx Apr 05 '16 at 21:13

0 Answers0