How do you register a Postgres container host on docker-compose up?

I have an app (Flask/Pony ORM) container that must register the host for a postgres db container on start up. How can I get the host’s (postgres container) location?

On my local set up I have “localhost” but this does not work in the app container.

  • How to use docker in both dev and production environment?
  • Docker container prefer host eth0 over wlan0 for internet
  • Vagrant + Docker + Postgresql - Cannot connect from host
  • Docker, Kafka - replication doesn't work between remote brokers
  • Rebuilding docker image is failing although using the same Dockerfile as shown in the hub
  • Facing Connection Timedout issue in RHEL7 OS while running the collectd-docker image
  • I tried “” which was what the pg containers IP when I was not using docker-compose.

    But both of these return an error.

    Is there a way to specify a host location for a particular container in the docker-compose file?

  • Unable to query consul DNS interface from host
  • How is docker able to mount a volume from docker client into a docker container running on docker host?
  • I have working with dockerfile to build and image and it build and run successfully but tomcat is not up
  • Why can't redis access the disk in docker-compose?
  • How can I fix 'No space left on device' error in Docker?
  • “I have no name!” as user logging into Jenkins in a docker container that uses Tini
  • One Solution collect form web for “How do you register a Postgres container host on docker-compose up?”

    You must link your two container in your docker-compose file. Then you will be able to access to your database using the service name of the container.


      - postgres:postgres

    Link your docker-compose.yml if you need more help.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.