0

Im am using docker compose to run 2 containers (both centos based). This is my yml:

front:
  build: front/docker/java
  ports:
    - "8080:8080"
  links:
    - back:db
back:
  build: back/docker/java
  ports:
    - "8081:8081"

But the front container gets nothing in the /etc/hosts for or env vars to be able to connect to the back container. I am running docker 1.3.2.

3
  • AFAIK docker won't touch /etc/hosts in the container. You should be getting a handful of environment variables like DB_PORT, DB_PORT_8081_TCP, etc as described in the docs. My guess is you might not be checking for the correct environment variable names or you might not be accessing environment variables correctly in your program. Could you post exactly how you are determining that you "get nothing"? Commented Mar 26, 2015 at 3:43
  • @PeterLyons yea turns out it was because i was using run instead of exec to list the env vars Commented Mar 26, 2015 at 3:47
  • 1
    There should be an update to /etc/hosts in front. Did you verify a entry for 'db' while exec'ed into front? In my local testing, I see 3 host updates for each link (compose invents some dns names). You also get the environment variables which are handy to programmatically wait for the other container's service to come online Commented Mar 26, 2015 at 12:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.