You are not logged in.

#1 2015-06-15 09:41:30

Archdove
Member
Registered: 2011-09-23
Posts: 118

Docker best Practices (Get IP of linked container)

I've recently started looking into docker, and I like what I see. The whole stuff is not too complex and it is easy to get something running.

There is one thing that I just couldn't figure out yet. What is the best way to get the IP address of a linked container?

I have an App which uses a Database. To App container is linked to the DB container, and on runtime, i see the respective entries in /etc/hosts and in ENV.

Since Docker states, that one should not use the environment variables because they won't get updated when a linked container restarts.
This leads me to the following problem: What is the recommended way to resolve a domain "postgres.databases.com" to an IP-Address using the /etc/hosts file.
Every Docker images is different. Some provide more tools and some less. And so I end up with a different Solution for each approach.

Do you have a solution?

Offline

#2 2015-06-22 05:29:56

Darksoul71
Member
Registered: 2010-04-12
Posts: 319

Re: Docker best Practices (Get IP of linked container)

There are several options based on your use case (expose port to your host, use bridge, etc).

I suggest you have a look at the following links:
https://docs.docker.com/articles/networking/
http://blog.sequenceiq.com/blog/2014/08 … etworking/

If network traffic does not need to leave the containers themself linking them might also be an option:
https://docs.docker.com/userguide/dockerlinks/

Last edited by Darksoul71 (2015-06-22 05:35:02)


My archlinux x86_64 host:
AMD E350 (2x1.6GHz) / 8GB DDR3 RAM / GeForce 9500GT (passive) / Arch running from 16GB USB Stick

Offline

Board footer

Powered by FluxBB