3

I am using tutum to deploy an application that involves web and db conponents. Here are the relevant parts of the tutum.yml file.

db:
  image: 'postgres:latest'
  ports:
    - '5432:5432'
  restart: always
  volumes_from:
    - data
web:
  image: 'rchamarthi/djangoweb:latest'
  command: 'bash -c ''python manage.py makemigrations && python manage.py migrate && /usr/local/bin/gunicorn django_project.wsgi:application -w 2 -b :8000'''
  expose:
    - '8000'
  links:
    - db
  restart: always
  volumes:
    - /usr/src/app/static
  working_dir: /usr/src/app/

Since web has a link to DB, iam expecting "db" host details to be added in the web container's /etc/hosts file, but I don't see anything.

In the web container

# cat /etc/hosts                                                                
172.17.0.50     web-1                                                           
127.0.0.1       localhost                                                       
::1     localhost ip6-localhost ip6-loopback                                    
fe00::0 ip6-localnet                                                            
ff00::0 ip6-mcastprefix                                                         
ff02::1 ip6-allnodes                                                            
ff02::2 ip6-allrouters 

In the DB container

# cat /etc/hosts                                                                
172.17.0.49     db-1                                                            
127.0.0.1       localhost                                                       
::1     localhost ip6-localhost ip6-loopback                                    
fe00::0 ip6-localnet                                                            
ff00::0 ip6-mcastprefix                                                         
ff02::1 ip6-allnodes                                                            
ff02::2 ip6-allrouters  

As a result, db connections from the web container are failing.

1 Answers1

0

According to https://support.tutum.co/support/solutions/articles/5000012181-service-links, "Tutum maintains a DNS service which is used automatically by all containers to resolve hostnames as described in this document". Presumably that's instead of the hosts file arrangement, which might be harder for tutum to manipulate dynamically. i.e. DNS can be updated at a central point without restarting all the containers that refer to it.

You'd also have environment variables which you can use to locate the linked services, but note that http://docs.docker.com/userguide/dockerlinks/ recommends that these cannot be relied on to update on container restarts.

mc0e
  • 5,866
  • 18
  • 31